Eliminating Unnecessary Implicit Allocations
summary
Ruby 3.4 eliminates several unnecessary implicit allocations: it fixes 3 allocation regressions found in ~2 weeks, adds an allocation test suite that prevents future regressions, and changes the VM to use new instructions (e.g., push_to_array and push_to_array_keyword_splat) so literal arrays and splatted calls now usually allocate a single array or no hash. Compiler changes move splat-dup logic into parse-time, fixing many caller-side splat allocations while preserving evaluation order.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 0:29Allocation regressions overview
- 1:56First allocation regression fix
- 2:39Second allocation regression fix
- 3:01Third allocation regression fix
- 4:04Allocation test suite creation
- 6:11Literal arrays optimization
- 9:00Large literal arrays issue
- 10:43Literal arrays with splats
- 12:24Keyword splats in arrays
- 13:25Caller-side splat allocations
- 18:43Args cat node optimization
- 20:29Safe splat allocation checks
- 25:44Evaluation order issue
- 28:32Unfixable implicit allocations
- 29:57Call-side implicit allocations
- 30:17Conclusion and Q&A
related talks
39mPointers for Eliminating Heaps of Memory
34mHow to optimize Ruby internal.
27mOptimizing Ruby's Memory Layout
27mNew Ruby 2.1 Awesomeness: Pro Object Allocation Tracing
46mRuby3: What's Missing?
27mPopping Into CRuby
45mClosing Keynote: Analyzing and Reducing Ruby Memory Usage
29mWhat causes Ruby memory bloat?
