Implementing Object Shapes for CRuby
summary
Ruby 3.2 ships a concrete implementation of Object Shapes in CRuby that replaces class‑caching with shape IDs, encodes frozen status, capacity and size pool, removes undef fills on allocation, and moves ivar indices to shape edges. Microbenchmarks and yjit codegen show it works: some ivar get/set microbenchmarks are several percent faster and yjit shows about a 45% speedup on ivar gets (yjit goes from ~3.37x to ~5.42x interpreter speed). An ObjectSpace.dump_shapes JSON API exposes the shape tree.
AI-written summary · about
chapters (11)
- 0:00Object shapes in Ruby
- 2:29Ruby 3.2 Christmas release
- 3:52What this talk will cover
- 4:54Instance variables in Ruby 3.1
- 9:31What object shapes are
- 14:05Implementing object shapes
- 17:16Performance gains
- 19:22Code complexity reduction
- 26:16Object shapes for JIT
- 31:34Object shapes Q&A
- 33:41Inspecting object shapes
related talks
34mImplementing Object Shapes in CRuby
34mDon't @ me! Faster Instance Variables with Object Shapes
53mRuby.inspect
41mHigh Performance Ruby
46mRuby3: What's Missing?
27mNew Ruby 2.1 Awesomeness: Pro Object Allocation Tracing
30mYJIT - Building a new JIT Compiler inside CRuby
27mOptimizing Ruby's Memory Layout
