Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba
-
Upload
fabio-akita -
Category
Technology
-
view
4.833 -
download
1
description
Transcript of Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba
![Page 1: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/1.jpg)
Ruby & GCsEntendendo Gerenciamento de Memória
![Page 2: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/2.jpg)
![Page 3: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/3.jpg)
![Page 4: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/4.jpg)
"G1 GC is an incremental parallel compacting GC that provides more predictable pause times compared to CMS GC and Parallel Old GC. By
introducing a parallel, concurrent and multi-phased marking cycle, G1 GC can work with
much larger heaps while providing reasonable worst-case pause times."
![Page 5: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/5.jpg)
"G1 GC is an incremental parallel compacting GC that provides more predictable pause times compared to CMS GC and Parallel Old GC. By
introducing a parallel, concurrent and multi-phased marking cycle, G1 GC can work with
much larger heaps while providing reasonable worst-case pause times."
![Page 6: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/6.jpg)
![Page 7: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/7.jpg)
![Page 8: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/8.jpg)
![Page 9: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/9.jpg)
![Page 10: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/10.jpg)
Obsoletos
1.8.6
1.8.7
1.9.2
![Page 11: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/11.jpg)
Obsoletos
1.8.6
1.8.7
1.9.2
Atuais
1.9.3
2.0.0
2.1.2
![Page 12: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/12.jpg)
Alocação de Memória malloc()
Limpeza de Lixo free()
![Page 13: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/13.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
![Page 14: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/14.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
![Page 15: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/15.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
![Page 16: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/16.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
![Page 17: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/17.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
![Page 18: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/18.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
0000 0000
0000 0000
0000 0000
0001 1001
![Page 19: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/19.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
0000 0000
0000 0000
0000 0000
0001 1001
![Page 20: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/20.jpg)
#include<stdio.h> int main() { int *ptr_one; ! ptr_one = (int *)malloc(sizeof(int)); ! if (ptr_one == 0) { printf("ERROR: Out of memory\n"); return 1; } ! *ptr_one = 25; printf("%d\n", *ptr_one); ! free(ptr_one); ! return 0; }
![Page 21: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/21.jpg)
Alocação de Memória malloc()
Detecção de Lixo ?
Limpeza de Lixo free()
![Page 22: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/22.jpg)
40 bytes livres
![Page 23: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/23.jpg)
Slot (40 bytes)
Heap (ex 6 slots)
![Page 24: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/24.jpg)
Slot (40 bytes)
Heap (ex 6 slots)
Instância de RVALUE
![Page 25: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/25.jpg)
typedef struct RVALUE { union { struct { VALUE flags; /* always 0 for freed obj */ struct RVALUE *next; } free; struct RBasic basic; struct RObject object; struct RClass klass; struct RFloat flonum; struct RString string; struct RArray array; struct RRegexp regexp; struct RHash hash; struct RData data; struct RTypedData typeddata; struct RStruct rstruct; struct RBignum bignum; struct RFile file; struct RNode node; struct RMatch match; struct RRational rational; struct RComplex complex; struct { struct RBasic basic; VALUE v1; VALUE v2; VALUE v3; } values; } as; #if GC_DEBUG const char *file; VALUE line; #endif } RVALUE;
RVALUE
![Page 26: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/26.jpg)
typedef struct RVALUE { union { struct { VALUE flags; /* always 0 for freed obj */ struct RVALUE *next; } free; struct RBasic basic; struct RObject object; struct RClass klass; struct RFloat flonum; struct RString string; struct RArray array; struct RRegexp regexp; struct RHash hash; struct RData data; struct RTypedData typeddata; struct RStruct rstruct; struct RBignum bignum; struct RFile file; struct RNode node; struct RMatch match; struct RRational rational; struct RComplex complex; struct { struct RBasic basic; VALUE v1; VALUE v2; VALUE v3; } values; } as; #if GC_DEBUG const char *file; VALUE line; #endif } RVALUE;
RVALUE
struct RString { struct RBasic basic; union { struct { long len; char *ptr; union { long capa; VALUE shared; } aux; } heap; char ary[RSTRING_EMBED_LEN_MAX + 1]; } as; };
RSTRING(str)->as.heap.ptr
![Page 27: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/27.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 28: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/28.jpg)
![Page 29: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/29.jpg)
![Page 30: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/30.jpg)
![Page 31: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/31.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 32: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/32.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 33: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/33.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 34: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/34.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 35: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/35.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 36: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/36.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 37: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/37.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 38: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/38.jpg)
Slot (40 kb)
Heap (ex 6 slots)
Instância de RVALUE
Dados do RVALUE
![Page 39: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/39.jpg)
Mark and Sweep GC
Full Marking and Full Sweep GC
![Page 40: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/40.jpg)
![Page 41: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/41.jpg)
• Slots de mesmo tamanho (não há problema com fragmentação)
![Page 42: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/42.jpg)
• Slots de mesmo tamanho (não há problema com fragmentação)
• Quanto mais heaps, mais lento
• Fase de marcação conservadora
![Page 43: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/43.jpg)
• Slots de mesmo tamanho (não há problema com fragmentação)
• Quanto mais heaps, mais lento
• Fase de marcação conservadora
• pode haver “leaks” (ex. constantes)
![Page 44: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/44.jpg)
• Slots de mesmo tamanho (não há problema com fragmentação)
• Quanto mais heaps, mais lento
• Fase de marcação conservadora
• pode haver “leaks” (ex. constantes)
• Processo “Stop-the-World"
![Page 45: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/45.jpg)
![Page 46: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/46.jpg)
![Page 47: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/47.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
request
150mb
![Page 48: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/48.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
fork()
request
150mb 150mb
![Page 49: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/49.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
Rails App
fork() fork()
request
150mb 150mb 150mb
![Page 50: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/50.jpg)
![Page 51: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/51.jpg)
Copy on Write (CoW)
só copia o trecho da memória quando for modificada
![Page 52: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/52.jpg)
![Page 53: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/53.jpg)
![Page 54: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/54.jpg)
“Mark Bit Map”
![Page 55: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/55.jpg)
“Mark Bit Map”
![Page 56: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/56.jpg)
“Mark Bit Map”
![Page 57: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/57.jpg)
“Mark Bit Map”
![Page 58: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/58.jpg)
“Mark Bit Map”
![Page 59: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/59.jpg)
Bitmap Marking GC
Full Bitmap Marking and Full Sweep GC
![Page 60: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/60.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
request
150mb
![Page 61: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/61.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
fork()
request
150mb 100mb
![Page 62: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/62.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
Rails App
fork() fork()
request
150mb 100mb 100mb
![Page 63: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/63.jpg)
Mark Sweep Mark Sweep Mark Sweep
![Page 64: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/64.jpg)
Mark Mark Mark
![Page 65: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/65.jpg)
Lazy Sweep GC
Full Bitmap Marking and Lazy Sweep GC
![Page 66: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/66.jpg)
![Page 67: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/67.jpg)
https://gist.github.com/akitaonrails/10212233
![Page 68: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/68.jpg)
http://u.akita.ws/samsaffron_ruby20
![Page 69: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/69.jpg)
![Page 70: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/70.jpg)
RUBY_GC_MALLOC_LIMIT=30000000 \
RUBY_HEAP_MIN_SLOTS=800000 \
bundle exec rails server
![Page 71: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/71.jpg)
![Page 72: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/72.jpg)
RUBY_GC_MALLOC_LIMIT 8.000.000 30.000.000
![Page 73: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/73.jpg)
RUBY_GC_MALLOC_LIMIT 8.000.000 30.000.000
RUBY_HEAP_MIN_SLOTS 10.000 800.000
![Page 74: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/74.jpg)
![Page 75: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/75.jpg)
![Page 76: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/76.jpg)
env_gc_malloc_limit_in_mb 7.6mb 26.6mb
![Page 77: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/77.jpg)
env_gc_malloc_limit_in_mb 7.6mb 26.6mb
total_gc_runs 105 65
![Page 78: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/78.jpg)
env_gc_malloc_limit_in_mb 7.6mb 26.6mb
total_gc_runs 105 65
heaps_with_used_slots 1.089 1.477
![Page 79: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/79.jpg)
env_gc_malloc_limit_in_mb 7.6mb 26.6mb
total_gc_runs 105 65
heaps_with_used_slots 1.089 1.477
total_heaps_allocated 1.958 1.965
![Page 80: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/80.jpg)
env_gc_malloc_limit_in_mb 7.6mb 26.6mb
total_gc_runs 105 65
heaps_with_used_slots 1.089 1.477
total_heaps_allocated 1.958 1.965
total_heaps_allocated_in_mb 30.6mb 30.7mb
![Page 81: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/81.jpg)
env_gc_malloc_limit_in_mb 7.6mb 26.6mb
total_gc_runs 105 65
heaps_with_used_slots 1.089 1.477
total_heaps_allocated 1.958 1.965
total_heaps_allocated_in_mb 30.6mb 30.7mb
heaps_to_allocate_next_gc 869 0
![Page 82: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/82.jpg)
![Page 83: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/83.jpg)
![Page 84: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/84.jpg)
71.9Mb
![Page 85: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/85.jpg)
2.49Mb
71.9Mb
![Page 86: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/86.jpg)
![Page 87: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/87.jpg)
![Page 88: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/88.jpg)
![Page 89: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/89.jpg)
![Page 90: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/90.jpg)
![Page 91: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/91.jpg)
![Page 92: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/92.jpg)
![Page 93: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/93.jpg)
![Page 94: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/94.jpg)
GC Anterior
![Page 95: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/95.jpg)
![Page 96: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/96.jpg)
![Page 97: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/97.jpg)
![Page 98: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/98.jpg)
![Page 99: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/99.jpg)
![Page 100: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/100.jpg)
![Page 101: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/101.jpg)
![Page 102: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/102.jpg)
![Page 103: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/103.jpg)
![Page 104: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/104.jpg)
![Page 105: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/105.jpg)
![Page 106: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/106.jpg)
![Page 107: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/107.jpg)
![Page 108: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/108.jpg)
![Page 109: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/109.jpg)
Weak Generational Hypothesis
“Most young objects die young"
![Page 110: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/110.jpg)
Young Generation (Eden)
Old Generation (Tomb)
![Page 111: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/111.jpg)
Generational GC
Copying Garbage Collector
![Page 112: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/112.jpg)
![Page 113: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/113.jpg)
![Page 114: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/114.jpg)
![Page 115: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/115.jpg)
![Page 116: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/116.jpg)
![Page 117: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/117.jpg)
![Page 118: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/118.jpg)
![Page 119: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/119.jpg)
![Page 120: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/120.jpg)
![Page 121: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/121.jpg)
From-Heap
To-Heap
![Page 122: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/122.jpg)
From-Heap
To-Heap
![Page 123: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/123.jpg)
From-Heap
To-Heap
![Page 124: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/124.jpg)
From-Heap
To-Heap
![Page 125: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/125.jpg)
From-Heap
To-Heap
![Page 126: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/126.jpg)
From-Heap
To-Heap
![Page 127: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/127.jpg)
From-Heap
To-Heap
![Page 128: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/128.jpg)
Mark-Compact GC
Mark Copy Compact Heap Swap GC
![Page 129: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/129.jpg)
![Page 130: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/130.jpg)
• “Stop-and-Copy”
![Page 131: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/131.jpg)
• “Stop-and-Copy”
• Sweep precisa ir slot a slot, neste é só considerar tudo no primeiro heap como livre
![Page 132: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/132.jpg)
• “Stop-and-Copy”
• Sweep precisa ir slot a slot, neste é só considerar tudo no primeiro heap como livre
• Gerenciamento interno de ponteiros
![Page 133: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/133.jpg)
• “Stop-and-Copy”
• Sweep precisa ir slot a slot, neste é só considerar tudo no primeiro heap como livre
• Gerenciamento interno de ponteiros
• Feito para corrigir fragmentação
![Page 134: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/134.jpg)
• “Stop-and-Copy”
• Sweep precisa ir slot a slot, neste é só considerar tudo no primeiro heap como livre
• Gerenciamento interno de ponteiros
• Feito para corrigir fragmentação
• Ruby tem slots de mesmo tamanho
![Page 135: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/135.jpg)
• “Stop-and-Copy”
• Sweep precisa ir slot a slot, neste é só considerar tudo no primeiro heap como livre
• Gerenciamento interno de ponteiros
• Feito para corrigir fragmentação
• Ruby tem slots de mesmo tamanho
• Não suporta Copy-on-Write
![Page 136: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/136.jpg)
Ruby 2.1.x
Shady vs Non-Shady
![Page 137: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/137.jpg)
Ruby Array
![Page 138: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/138.jpg)
Ruby Object
Ruby Array
![Page 139: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/139.jpg)
Ruby Object
Write Barrier (Non-Shady only)
Ruby Array
![Page 140: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/140.jpg)
Shady Object
Non-Shady Object (Sunny)
![Page 141: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/141.jpg)
Mark bitmap (mark_bits[])
Shady bitmap ( rememberset_bits[])
![Page 142: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/142.jpg)
Mark bitmap (mark_bits[])
Shady bitmap ( rememberset_bits[])
![Page 143: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/143.jpg)
![Page 144: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/144.jpg)
Objetos "Old" 96.4%
![Page 145: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/145.jpg)
Objetos "Old" 96.4%
Objetos "Young" 3.6%
![Page 146: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/146.jpg)
Objetos "Old" 96.4%
Objetos "Young" 3.6%
Objetos "Shady" 1.5%
![Page 147: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/147.jpg)
Mark Mark Mark
![Page 148: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/148.jpg)
![Page 149: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/149.jpg)
Major GC
Minor GC
![Page 150: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/150.jpg)
2.49Mb
71.9Mb
![Page 151: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/151.jpg)
![Page 152: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/152.jpg)
![Page 153: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/153.jpg)
Restricted Generational GC (RGenGC)
Full M&S for Shady, Generational for Non-Shady
![Page 154: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/154.jpg)
![Page 155: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/155.jpg)
• Partial Markings, Lazy Sweeps = Menos Stop
![Page 156: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/156.jpg)
• Partial Markings, Lazy Sweeps = Menos Stop
• Shady objects não vão para o Tomb
![Page 157: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/157.jpg)
• Partial Markings, Lazy Sweeps = Menos Stop
• Shady objects não vão para o Tomb
• Write Barriers (referência old para new - non-Shady only)
![Page 158: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/158.jpg)
• Partial Markings, Lazy Sweeps = Menos Stop
• Shady objects não vão para o Tomb
• Write Barriers (referência old para new - non-Shady only)
• Compatível com extensões C (Shady)
![Page 159: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/159.jpg)
• Partial Markings, Lazy Sweeps = Menos Stop
• Shady objects não vão para o Tomb
• Write Barriers (referência old para new - non-Shady only)
• Compatível com extensões C (Shady)
• Objetos em Tomb só são remarcados em Full Mark
![Page 160: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/160.jpg)
![Page 161: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/161.jpg)
![Page 162: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/162.jpg)
![Page 163: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/163.jpg)
![Page 164: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/164.jpg)
< 1.3!(+ major GC)
![Page 165: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/165.jpg)
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.3
bundle exec rails server
força GC por diminuir o teto
basicamente desabilita minor GC
(de volta a Ruby 2.0.0)
![Page 166: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/166.jpg)
@retained = []@rand = Random.new(999)!MAX_STRING_SIZE = 100!def stress(allocate_count, retain_count, chunk_size) chunk = [] while retain_count > 0 || allocate_count > 0 if retain_count == 0 || (@rand.rand < 0.5 && allocate_count > 0) chunk << " " * (@rand.rand * MAX_STRING_SIZE).to_i allocate_count -= 1 if chunk.length > chunk_size chunk = [] end else @retained << " " * (@rand.rand * MAX_STRING_SIZE).to_i retain_count -= 1 end endend!start = Time.now# simulate rails boot, 2M objects allocated 600K retained in memorystress(2_000_000, 600_000, 200_000)!# simulate 100 requests that allocate 100K objectsstress(10_000_000, 0, 100_000)
http://u.akita.ws/ruby212ready
![Page 167: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/167.jpg)
Ruby 2.0 10 seg 119 mb
Ruby 2.1.1 7 seg 230 mb
ruby stress.rb
http://u.akita.ws/ruby212ready
![Page 168: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/168.jpg)
Ruby 2.0 10 seg 119 mb
Ruby 2.1.1 7 seg 230 mb
1.3 6.85 seg 180 mb
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.3 ruby stress.rb
http://u.akita.ws/ruby212ready
![Page 169: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/169.jpg)
Ruby 2.0 10 seg 119 mb
Ruby 2.1.1 7 seg 230 mb
1.3 6.85 seg 180 mb
0.9 6.75 seg 146 mb
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0.9 ruby stress.rb
http://u.akita.ws/ruby212ready
![Page 170: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/170.jpg)
Ruby 2.0 10 seg 119 mb
Ruby 2.1.1 7 seg 230 mb
1.3 6.85 seg 180 mb
0.9 6.75 seg 146 mb
8 mb 9 seg 117 mb
RUBY_GC_MALLOC_LIMIT_MAX=8000000 \ RUBY_GC_OLDMALLOC_LIMIT_MAX=8000000 \ RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0.9 ruby stress.rb
http://u.akita.ws/ruby212ready
![Page 171: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/171.jpg)
RUBY_GC_MALLOC_LIMIT_MAX 3210241024 8000000
RUBY_GC_OLDMALLOC_LIMIT_MAX 12810241024 8000000
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0 1.3
RUBY_GC_HEAP_INIT_SLOTS 10000 300000
RUBY_GC_HEAP_FREE_SLOTS 4096 300000
RUBY_GC_HEAP_GROWTH_FACTOR 1.8 1.25
RUBY_GC_HEAP_GROWTH_MAX_SLOTS (no limit) 150000
(obs: monitore, mensure, tuning, mensure de novo!)
http://tmm1.net/ruby21-rgengc/
![Page 172: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/172.jpg)
![Page 173: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/173.jpg)
![Page 174: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/174.jpg)
• Objetos vão para Tomb se sobreviverem 1 GC
![Page 175: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/175.jpg)
• Objetos vão para Tomb se sobreviverem 1 GC
• Objetos podem ir para Tomb cedo demais
![Page 176: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/176.jpg)
• Objetos vão para Tomb se sobreviverem 1 GC
• Objetos podem ir para Tomb cedo demais
• Eden - Survivor - Tenured - Permanent
![Page 177: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/177.jpg)
• Objetos vão para Tomb se sobreviverem 1 GC
• Objetos podem ir para Tomb cedo demais
• Eden - Survivor - Tenured - Permanent
• RGENGC_THREEGEN mode (experimental 2.2)
![Page 178: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/178.jpg)
• Objetos vão para Tomb se sobreviverem 1 GC
• Objetos podem ir para Tomb cedo demais
• Eden - Survivor - Tenured - Permanent
• RGENGC_THREEGEN mode (experimental 2.2)
• Parallel Marking (ex. em Thread separada)
• Tri-Color Marking (talvez)
![Page 179: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/179.jpg)
• Objetos vão para Tomb se sobreviverem 1 GC
• Objetos podem ir para Tomb cedo demais
• Eden - Survivor - Tenured - Permanent
• RGENGC_THREEGEN mode (experimental 2.2)
• Parallel Marking (ex. em Thread separada)
• Tri-Color Marking (talvez)
• Futuro: Incremental Major Phase (major GC menores)
![Page 180: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/180.jpg)
Java• Young Generation
• -XX:+UseSerialGC (copying collector)
• -XX:+UseParallelGC (copying collector multi-thread)
• -XX:+UseParNewGC
• Old Generation
• -XX:+UseParallelOldGC
• -XX:+UseConcMarkSweepGC
![Page 181: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/181.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
request
190ms
![Page 182: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/182.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
Rails App
request
190ms 190ms 190ms
![Page 183: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/183.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
Rails App
request
190ms 190ms 190ms
50ms de Full GC!
![Page 184: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/184.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
request
140ms 140ms
Executa Full GC quando não receber request
![Page 185: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/185.jpg)
Master Unicorn ou Passenger
Rails App
NGINX
Rails App
Rails App
request
140ms 140ms Full GC
Executa Full GC quando não receber request
![Page 186: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/186.jpg)
OOBGC
Out-of-Band Major GC
![Page 187: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/187.jpg)
![Page 188: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/188.jpg)
![Page 189: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/189.jpg)
http://tmm1.net/ruby21-oobgc/
![Page 190: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/190.jpg)
Pausas foram de 125ms para 50ms
http://tmm1.net/ruby21-oobgc/
![Page 191: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/191.jpg)
![Page 192: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/192.jpg)
![Page 193: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/193.jpg)
CUIDADO!!
![Page 194: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/194.jpg)
CUIDADO!!
![Page 195: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/195.jpg)
http://u.akita.ws/rubymicroscope
![Page 196: Ruby & GCs (versão 2.1.2) - VI Secot UFScar Sorocaba](https://reader033.fdocuments.net/reader033/viewer/2022060108/554f3c3eb4c905471e8b4a85/html5/thumbnails/196.jpg)
Obrigado!@akitaonrails
slideshare.net/akitaonrails www.akitaonrails.com