~/talk

Automatic GC Compaction in MRI

Talkat RubyConf 2020 · 2020-11-17..11-19· [ruby, compilers-and-language-design]
slides:none on file

Automatic compaction becomes a concurrent step that runs with sweeping, implemented with a mprotect read barrier that moves objects back when protected pages are touched. Heap pages expand to exactly 16 KB pages (adding one 40‑byte slot) so pages are mprotect-able. Batching moves at page boundaries reduces calls to mprotect to about 2 calls per ~200 moved objects versus two calls per object, recovering performance after an initial implementation that was ~4.5× slower. Tools: rdoc benchmark (50 runs) and Instruments profiler; feature is functional but auto compaction is off by default because it increases major GC time.

AI-written summary · about

  1. 0:00Intro
  2. 2:05Heap Compaction In a Rails app
  3. 2:24Heap Before Compaction
  4. 3:21Compaction Process
  5. 5:50Compaction Goals
  6. 6:33Heap Comparison Before and After Compaction
  7. 8:01Empty Destination Required! Movement
  8. 10:49Sweep Process After Marking
  9. 12:33Sweep + Update References Sweep is Paused
  10. 13:02Sweep Continues Finish up!
  11. 13:56Ruby Class Hierarchy
  12. 14:47Sweep Process Sweeping Classes
  13. 15:15Sweep + Move Process After Marking
  14. 15:53Crash Backtrace
  15. 19:02mprotect() requirements
  16. 20:46Memory Usage Over Time jemalloc
  17. 21:05Old Size vs New Size
  18. 22:15Page Widen Diff
  19. 22:39Compact + Read Barrier
  20. 23:24Using Instruments
  21. 23:53Bottleneck: mprotect
  22. 27:25Comparing to Master
  23. 28:35Automatic Compaction in Action
  24. 29:07Auto Compaction Control
  25. 31:08Major GC: Objects Per Second (higher is better)
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.