Reduce Memory by Using More
summary
A patch changes heap pages to 16KB pages so jemalloc uses full buckets, yielding about ~10% memory saving in rdoc benchmarks (50 runs) by eliminating internal fragmentation. Concurrent compaction is implemented with an mprotect read barrier and per-page packing so reference updates still pause but movement runs alongside sweeping. Profiling with Instruments shows mprotect was costly until batched per-page movement amortizes calls, bringing performance back near baseline.
AI-written summary · about
chapters (20)
- 0:00Start
- 7:28Heap Before Compaction
- 7:40Heap After Compaction
- 10:57Compaction Goals
- 16:54Sweep Process After Marking
- 21:21Ruby Class Hierarchy
- 22:16Sweep Process Sweeping Classes
- 23:54Crash Backtrace
- 25:23Where to add read barriers?
- 26:16Read Barrier Execution Point
- 28:32Ruby Page Allocation
- 28:49HEAP PAGE ALIGN
- 30:20Memory Usage Over Time jemalloc
- 31:03Old Size vs New Size
- 32:08Page Widen Diff
- 32:37Compact + Read Barrier
- 34:09Using Instruments
- 34:57Bottleneck: mprotect
- 38:35Comparing to Master
- 40:08Automatic Compaction in Action
related talks
46mHalve Your Memory Usage With These 12 Weird Tricks
34mAutomatic GC Compaction in MRI
46mRuby Memory Management Hacks
39mPointers for Eliminating Heaps of Memory
54mKeynote: Exploring Memory in Ruby - Building a Compacting GC
47mCompacting Heaps in Ruby 2.7
27mParallel Ruby: Managing the Memory Monster
29mWhat causes Ruby memory bloat?
