Copy
You're reading the Ruby/Rails performance newsletter by Speedshop.

Last week, I tore down a real prod Rails app live, on stream, evaluating it's performance with New Relic.

Maybe. Ruby 3's killer features need implementation in libraries, and perf will probably be the same as 2.7.

I sometimes like to subvert clickbait journalism by containing the answer to "questions in the headline" in the first sentence. So, if that's all you needed, stop reading. If you're interested in more detail, read on!

Any question about "should I upgrade?" needs to answer "what changed?".
  • RBS and Typeprof. If you're into static typing and you want to use The Official Ruby Way To Do It, you need to upgrade to Ruby 3. There is of course, also Sorbet, which probably won't go anywhere soon as it's baked in to the codebase at Stripe, and you can use that today on Ruby 2.7.
  • Ractor and the Fiber Scheduler. Both of these new APIs solve similar problems (concurrency) but in slightly different ways. Ractors introduce true parallelism through an Actor-like approach, and the Fiber Scheduler aims to make "event loop" style concurrency easier. Both APIs will generally be used solely at the library level, and will probably not be used in many applications directly. That means there's no point in upgrading for these features until libraries actually use them, which hasn't happened yet.
  • Lots of Cool Syntax Bois, like the find pattern, endless method definition, Hash#except and argument forwarding.
Ractors are probably the most exciting feature for me, personally. They're the fulfillment of a 20-year dream to "kill the GIL" and have a lot of potential. I'm going to try to adding them Puma's internals soon. But like I said previously, I see their usage in a typical web application pretty limited outside of the libraries and dependencies you're going to pull in.

So that kind of leaves typing - and only if you really want to stick with RBS over Sorbet - as the only reason you should definitely upgrade to Ruby 3.0 today.

But what about Ruby 3x3, Nate? I've talked about this in other newsletters, but one bit of misinformation I've seen going around lately is that Ruby 3 should have been significantly faster than Ruby 2.7, and that Rails should have been 3x faster too.

Anyone expecting a massive latency improvement when upgrading from Ruby 2.7 to Ruby 3.0 will be sorely disappointed, because that was never what Ruby 3x3 was about. Ruby 3x3 was a promise that Ruby 3 would be 3 times faster than Ruby 2.0. As Noah Gibbs has pointed out in his blogs over the years, most of the performance improvement over the 2.x series occurred in the first three minor version releases (2.1, 2.2 and 2.3).

It looks like in the real world, Ruby 3.0 performance is "the same as 2.7 or slightly worse". It's hard to tell, as Sam Saffron has claimed on Twitter that Ruby 3 makes Discourse slower, but Noah's own benchmarking on the same app says that performance is the same. So, it sounds like perf versus 2.7 is a bit of a wash.

So it's not a blow-the-doors-off, upgrade-today kind of release. But it didn't have to be - it set down some major new features that will be developed over the next few years, and those things will need the ecosystem to change and develop, and that takes time. So you don't have to upgrade today, but you certainly will some time soon.

Until next week,

Nate
 
You can share this email with this permalink: https://mailchi.mp/railsspeed/should-you-upgrade-to-ruby-30?e=[UNIQID]

Copyright © 2021 Nate Berkopec, All rights reserved.


Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list.