Splitting: the Crucial Optimization for Ruby Blocks
summary
Explains that splitting makes multiple, caller-specialized copies of a method so the JIT can compile method+block together, enabling aggressive inlining and constant folding. Demonstrates on a numeric step example, implemented on Truffle/TruffleRuby, removing polymorphism and turning branchy Ruby loops into C‑like tight loops. Reports concrete results: 7.7× speedup on the microbenchmark and claims up to 100× vs CRuby in one case, with memory growth controlled by limits.
AI-written summary · about
chapters (19)
- 0:00Splitting optimization intro
- 1:25Splitting in Self language
- 3:29Sum_to method example
- 4:30JIT inlining challenges
- 7:17Numeric step complexity
- 9:21Polymorphic block problem
- 10:46Splitting resolves polymorphism
- 12:11Splitting optimization benefits
- 12:32Monomorphic vs megamorphic
- 13:34Recursive splitting for nesting
- 15:37Profiling and type specialization
- 18:45Optimized step method
- 19:48Performance vs C
- 20:50Benchmarking splitting impact
- 21:53Optcarrot and Rails gains
- 22:56TruffleRuby speedup
- 23:18Polymorphism research
- 25:04Conclusion and future
- 26:11Q&A: Memory trade-offs
related talks
28mWho You Gonna Call: Analyzing the Run-time Call-Site Behavior of Ruby Applications
57mRuby: 2020
30mFast Metaprogramming with Truffle
53mWriting Fast Ruby
38mRuby Unblocked
28mRuby Racing: Challenging Ruby Methods
41mPerformance Improvement of Ruby 2.7 JIT in Real World
34mHow to optimize Ruby internal.
