Speeding Up Ruby by Rewriting C in RubyPermalink

JP Camara:

There is a recent language comparison repo which has been getting shared a lot. In it, CRuby was the third slowest option, only beating out R and Python.

With YJIT, Fibonacci gets a massive boost - going from 16.88 seconds down to 2.06 seconds. It’s close to the speed of node.js at that point!

YJIT makes a more modest difference for the looping example - going from 33.43 seconds down to 25.57 seconds. Why is that?

Interesting dive into the newer 1 Ruby internals with the YJIT JIT compiler. I also find it fascinating to see the spread of times across the languages, ranging half a second to over a minute — to produce exactly the same result!

  1. For about a decade Ruby was my primary programming language. However, it’s been 5 years since I stopped using it regularly and a lot has changed in that time. I did write the new-post script for this site in Ruby though.