Grow and Shrink - Dynamically Extending the Ruby VM Stack
summary
MRI gains dynamic per-thread stacks with two concrete implementations: a stretch approach that allocates a larger region and copies the stack, and a chain approach that keeps a small live stack plus movable internal stack. Default thread stack is 1MB default and new env vars set initial and maximum sizes. Implementation fixes all internal pointers, copies C-level argument arrays, uses stack overflow detection, and employs page-protect to catch stale pointers. On Linux this cuts per-thread memory by up to 30% at about a 6% average runtime cost.
AI-written summary · about
chapters (6)
- 0:00Introduction
- 3:44Ruby VM stack basics
- 11:14Stack stretch extension
- 21:36Alternative chain method
- 28:08Memory usage evaluation
- 33:45Future directions and Q&A
related talks
29mWhat causes Ruby memory bloat?
26mGo Stack: Should It Be Moving Like That?
27mParallel Ruby: Managing the Memory Monster
39mPointers for Eliminating Heaps of Memory
46mRuby Memory Management Hacks
49mMethods of Memory Management in MRI
48mMethods of Memory Management in MRI
28mDeploy, Scale and Sleep at Night with JRuby
