Don't @ me! Faster Instance Variables with Object Shapes
summary
Claims concrete speedups: using Object Shapes (shape IDs stored in object headers) plus inline caches and JIT integration reduces instance-variable read cost from about 2.7× faster on the VM to ~5.4× under JIT, makes IV writes about 21% faster, and cuts class-related memory use (John Hawthorne reports ~16 MB saved). Implementation treats undefined IVs via Q on Def, encodes frozen/extended state as shape transitions, and ships alongside Ruby 3.2 and YJIT work.
AI-written summary · about
chapters (11)
- 0:00Start
- 5:23Hash based implementation
- 5:53Tree Walking Interpreter
- 13:05Cache Lookup Problem
- 15:10Handling "Undefined" Instance Variables
- 17:05Conditionals for Reading an IV
- 17:50Machine Code for Reading an IV
- 18:51Shape Transitions on Write
- 23:20Freezing Changes Shape
- 28:13Machine Code for reading one IV
- 33:01Benchmark Comparison
related talks
35mImplementing Object Shapes for CRuby
34mImplementing Object Shapes in CRuby
41mHigh Performance Ruby
27mWhose Memory is it Anyway
46mRuby Memory Management Hacks
29mLightning-Fast Method Calls with Ruby 4.1 ZJIT
40mThe secret power of Ruby 2.6: JIT
27mThe design and implementation of ZJIT & the next five years
