How are Method Calls Formed?
summary
Shows how Ruby resolves method calls from bytecode into C and claims a speedup by adding a polymorphic inline cache. Implements the cache as a short array (an 186 line diff), instruments MRI with a TracePoint logger and runs real workloads (1,600 requests producing ~4 million calls). Benchmarks show microbenchmarks improve but the production trace reveals most call sites are monomorphic so the patch yields little net benefit; discovers RSpec and EventMachine patterns that cause cache churn.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 7:58Method call sites in Ruby
- 13:40Ruby VM executes method calls
- 18:54Method lookup and inheritance
- 21:42Speeding up with inline caching
- 23:29Breaking method caches
- 27:24Detecting cache misses with stats
- 30:18Cache breaks and Singleton classes
- 33:10Polymorphic calls and performance
- 36:20Polymorphic inline caches
- 37:46Measuring optimization impact
- 40:52Analyzing call sites in production
- 45:51Lessons learned
related talks
52mHow Are Method Calls Formed?
33mUnderstanding Ruby's Method Cache
28mWho You Gonna Call: Analyzing the Run-time Call-Site Behavior of Ruby Applications
30mFast Metaprogramming with Truffle
41mPerformance Improvement of Ruby 2.7 JIT in Real World
40mImplementation Details of Ruby 2.0 VM
57mRuby: 2020
38mCool, But... Why?
