Ruby 3.1 experiments with YJIT

JIT (Just-In-Time) compiler was first introduced as an experimental feature in Ruby 2.6 with the intention of improving the performance of Ruby programs. Being experimental, memory-intensive workloads such as Rails application could not benefit from it at the moment of it’s introduction, despite achieving 1.7x faster performance as compared to Ruby 2.5.

In a similar fashion, Ruby 3.1 has introduced YJIT by Shopify. The technology is aimed at improving the performance of Ruby applications.

Shopify is known for its Ruby-based technology, which powers the Shopify eCommerce platform. Since the introduction of YJIT, we’ve been able to see the benefits it offers to our software, including increased startup speed and compatibility with GitHub’s Parcel toolchain.

The main benefits of YJIT are:

-Speed up the performance of your application by running the compiled version of your code instead of interpreting it.

-Reduce memory usage by enabling more efficient use of memory, which translates into less garbage collection overhead.

YJIT also adds support for:

However, being an experimental feature, it is disabled by default and has to be explicitly specified in order to be used. The command-line option to enable it is --yjit. The following resources would be helpful: