Today is Christmas, which means version 3.2.0 of Ruby has been released. I read Peter Solnica’s post about Benchmarking Ruby 3.2 with YJIT. One bit of feedback he got was that YJIT — the now official Just In Time compiler — kicks in for frequently called methods:
By default, YJIT optimizes a method on the 30th time you call it.
— Noah Gibbs, Ruby.social
Well hey. The Nanoc iteration of my site has a few hundred pages. Nanoc probably calls some of its methods 30 or more times for that. Let’s find out if 3.2.0 makes a difference.
I should probably install 3.2.0
This is in my Windows 11 + WSL2 workspace. I wouldn’t be surprised if Linux and macOS tests went faster.
Installed 3.2.0 on my system using rbenv
. Worth mentioning that I had to export CC=/home/linuxbrew/.linuxbrew/bin/gcc-12
for rbenv install
to work at all. For some reason I had a brew
-installed Ruby floating around, too. Removed that with brew uninstall ruby
so rbenv install 3.2.0
would work.
I have a very fiddly system.
The “test”
- Switch to the right version
- Install dependencies for that version
- Build the site
- Build it again, to see how long things take when nothing’s changed
- Remove the build folder and move on to the next case
First in 3.1.3 to set a baseline of sorts.
Don’t judge those numbers too harshly. Nanoc site configuration is Ruby code, and mine was very sloppy Ruby code. Regardless, it’s way slower than Hugo.
Now in 3.2.0 without enabling YJIT, to see if just the plain old upgrade is quicker.
There’s variation from one invocation to the next in 3.1.3, but 3.2.0’s first build is consistently a sliver faster than 3.1.3’s second build.
Finally with YJIT.
That is an impressive difference. We’re still not talking Hugo numbers, of course. But under 30 seconds means I might be able to pay attention long enough to fix my terrible site configuration code.
Backlinks
Got a comment? A question? More of a comment than a question?
Talk to me about this page on: mastodon
Added to vault 2024-01-15. Updated on 2024-04-01