Implementing Object Shapes in CRuby
summary
Implements object shapes in CRuby and lands in Ruby 3.2 to replace per-class ivar maps with a shape tree keyed by shape ID, using 32-bit IDs on 64-bit platforms (~4.2B possible shapes) and 16-bit on 32-bit. Benchmarks show Railsbench uses ~10k shapes and Shopify monolith test suite hits 40,000 shapes. Changes remove undf prefill, eliminate fast-path frozen checks, improve JIT-generated code size, and produce microbenchmark wins including a notable 2× speedup on an inherited-ivar workload.
AI-written summary · about
chapters (8)
- 0:00Ruby 3.2 features
- 1:52Object shapes in CRuby
- 9:41Implementing object shapes
- 16:03Benefits of object shapes
- 23:11Reducing code complexity
- 29:35Object shapes and JIT
- 31:00Performance improvements
- 33:26Summary








