Fast Metaprogramming with Truffle
summary
Claims that JRuby+Truffle removes most metaprogramming overhead by using localized caching and dispatch chains to turn send, instance_variable_get/set and method_missing into direct calls. Microbenchmarks show ~4x faster method calls, ~5x faster ivar ops and ~10x faster method_missing versus MRI; a larger benchmark (pdf processing) runs ~33x faster. Implementation pulls JRuby and Rubinius code, hits ~90% core lib, ~92% language spec and ~99% ActiveSupport tests, and the technique deoptimizes and falls back when call sites go megamorphic.
AI-written summary · about
chapters (15)
- 0:00Introduction and disclaimer
- 0:47What is Truffle framework
- 3:59Metaprogramming in Ruby
- 5:49Performance and elegance in Ruby
- 6:52Metaprogramming microbenchmarks
- 8:17Truffle eliminates metaprogramming overhead
- 9:21Frequency of metaprogramming calls
- 13:15JRuby+Truffle performance gains
- 14:21Ruby method lookup basics
- 18:52Inline caching in Ruby
- 21:00Dispatch chains for metaprogramming
- 24:18Method sharing and caching
- 25:46Making metaprogramming fast
- 27:13Research and implementation
- 27:58Q&A on dispatch chains
related talks
47mHigh Performance Ruby
43mParallel and Thread-Safe Ruby at High-Speed with TruffleRuby
41mHigh Performance Ruby
24mJust-in-Time Compiling Ruby Regexps on TruffleRuby
42mImproving TruffleRuby’s Startup Time with the SubstrateVM
20mEvaluating YJIT’s Performance in a Production Context: A Pragmatic Approach
44mImproving TruffleRuby’s Startup Time with the SubstrateVM
38m"Parallel and Thread-Safe Ruby at High-Speed with TruffleRuby"
