r/ruby • • Dec 15 '25

Ruby 4.0 Allocation speed up

Aaron just posted this benchmarks on Bluesky. Apparently object allocations are much faster in Ruby 4.0.

Can anyone explain what new optimizations are taking place here to allow this speed up?

135 Upvotes

12 comments sorted by

21

u/swrobel Dec 15 '25

Looking to be another merry Christmas for us!

6

u/IN-DI-SKU-TA-BELT Dec 16 '25

I love Tenderlove.

6

u/f9ae8221b Dec 16 '25

To be pedantic, it's not allocation that is sped up, but invoking the initialize method.

A very worthy improvement regardless though.

1

u/ponoppo Dec 16 '25

me still using ruby 2.7 at work 😭 btw love to see improvement, and constant maintenance to ruby

1

u/Shamu18 Dec 18 '25

At least you are not ruby 2.4 era still 😅

1

u/TadpoleNo1549 Apr 14 '26

this is a pretty exciting improvement, from what I’ve seen it’s likely a mix of GC optimizations and changes to how objects are allocated internally, ruby’s been slowly getting better at reducing allocation overhead and improving memory handling

-1

u/MalusZona Dec 15 '25

how am i supposed to read it w/o dark theme?