Ruby is taking new approaches to performance, from JIT compilation to parallel execution. Explore how YJIT, ZJIT, and Ractors are evolving, the engineering decisions behind them, and what these changes mean for Ruby developers.

Ruby performance is improving on two fronts: YJIT and ZJIT are changing how Ruby compiles and executes code, while Ractors make it possible to run independent workloads in parallel.

They solve different problems: JITs make Ruby code run faster, and Ractors let it run on more cores.

In short: YJIT is Ruby's production-ready JIT today. ZJIT, which shipped as experimental in Ruby 4.0, reached YJIT-level response times at Shopify in October 2026 with about 19% less JIT memory. Ractors, Ruby's model for true parallelism, get per-Ractor garbage collection in Ruby 4.1, which removes a major source of cross-Ractor pauses.

Ruby Has Two Different Performance Challenges

Making a program faster is not always the same as making it execute more work at once.

Consider a CPU-intensive Ruby operation. It might spend most of its time executing Ruby instructions, performing method calls, and allocating objects. Improving the execution of those instructions can make the entire operation faster.

Now consider an application processing several independent workloads. Even when a machine has multiple CPU cores available, traditional Ruby threads cannot execute Ruby code simultaneously on all those cores within the same CRuby process.

Just-in-time (JIT) compilation addresses the first problem. It analyzes code while a program is running and compiles frequently executed paths into native machine instructions.

Ractors address the second one. They provide isolated execution environments that can run Ruby code in parallel on multiple CPU cores.

Ruby has been investing in both areas. The evolution of YJIT and the development of ZJIT represent important changes to its execution engine, while improvements to Ractors are making parallel execution more practical.
JIT compilation turns Ruby code into machine code; Ractors run independent workloads on separate CPU cores.
JIT compilation turns Ruby code into machine code; Ractors run independent workloads on separate CPU cores.

From MJIT to YJIT

Ruby 2.6 introduced MJIT, its first official JIT compiler, in December 2018.

MJIT generated C code for methods selected for compilation, then invoked an external C compiler to produce machine code. While this allowed Ruby to reuse existing compiler infrastructure, the process introduced overhead from code generation, disk operations, and compiler invocation.

More importantly, benchmark improvements did not always translate into faster real-world applications. Ruby 3.1's release announcement acknowledged this gap, particularly for business workloads. MJIT was eventually removed in Ruby 3.3.

Shopify took a different approach with YJIT.

Unlike MJIT, YJIT runs inside the Ruby process and generates machine code directly. Introduced in Ruby 3.1, it uses Lazy Basic Block Versioning (LBBV) to specialize code based on actual execution.

How Lazy Basic Block Versioning Works

Ruby's dynamic typing makes ahead-of-time optimization difficult. The same method can receive objects of different types, so a compiler cannot always predict which operations will be executed.

YJIT addresses this by observing execution and compiling only the basic blocks that are actually reached.
A basic block is a sequence of instructions with a single entry and exit point. When YJIT encounters a block with known types, it can generate specialized machine code for that context.

Consider:
def calculate(value)
  value + 10
end
When the method receives an Integer, YJIT can generate optimized code for that type. If another type appears later, it can generate another version of the block when supported.

Guards validate the compiler's assumptions. When one fails, execution exits the compiled code and returns to the interpreter.

This allows YJIT to optimize the paths an application actually uses instead of trying to predict every possible execution scenario.

By Ruby 3.2, YJIT was mature enough for Shopify to deploy across its Storefront Renderer infrastructure.
YJIT compiles basic blocks for the types it observes and exits to the interpreter when a type guard fails.
YJIT compiles basic blocks for the types it observes and exits to the interpreter when a type guard fails.

ZJIT and Static Single Assignment

YJIT brought substantial improvements, but its architecture also limited how much code could be analyzed together.

ZJIT, developed by Shopify's compiler team, takes a different approach. Merged into Ruby in May 2025, it became available in Ruby 4.0.

While YJIT specializes individual basic blocks incrementally, ZJIT profiles execution and compiles entire methods using a higher-level intermediate representation based on Static Single Assignment (SSA).

This gives ZJIT more room to optimize operations across basic blocks, while YJIT focuses on incremental specialization. ZJIT's modular architecture also makes it easier to develop and experiment with different compiler optimizations.
YJIT vs. ZJIT at a glance:
  • Compiles: YJIT compiles individual basic blocks as they run. ZJIT compiles whole methods from interpreter profiles.
  • Approach: YJIT uses Lazy Basic Block Versioning. ZJIT uses an SSA-based intermediate representation.
  • First shipped: YJIT in Ruby 3.1. ZJIT in Ruby 4.0 (experimental).
  • JIT memory at Shopify: YJIT 125 MiB. ZJIT 101 MiB.

ZJIT vs. YJIT: Early Production Results

When Ruby 4.0 was released in December 2025, ZJIT was faster than the interpreter but still behind YJIT. It was considered experimental, and production deployment was not recommended.

By October 2026, Shopify had started deploying it to selected Storefront Renderer regions.

Max Bernstein shared initial results showing promising response times and lower JIT memory consumption:
  • YJIT: 125 MiB
  • ZJIT: 101 MiB
That is approximately 19.2% less JIT memory with ZJIT. These figures refer to JIT memory overhead, not total process memory.

In a 24-hour production comparison, ZJIT regions also appeared to serve requests slightly faster. However, this was not a controlled benchmark: the comparison involved a small number of regions running in different locations, and absolute response time values were not published.

Some benchmarks were still slower than YJIT. At the time, ZJIT lacked support for some complex calling convention features and exception handlers, and its backend did not yet support floating-point operations.

These numbers come from one application; benchmark your own before drawing conclusions.

Ractors and Parallel Execution

JIT compilation improves how efficiently Ruby executes code, but it doesn't change CRuby's threading model or remove its Global VM Lock (GVL).

Threads are useful for I/O-bound operations, such as database queries and HTTP requests. However, CPU-intensive Ruby code running in multiple threads within the same Ractor still shares the GVL, preventing parallel execution.

Introduced in Ruby 3.0, Ractors provide isolated execution environments that allow Ruby code to run in parallel across different CPU cores. Each Ractor has its own GVL and isolation boundary.
The main Ractor sends values to worker Ractors, each with its own heap. Mutable objects must be copied or moved.
The main Ractor sends values to worker Ractors, each with its own heap. Mutable objects must be copied or moved.

Ractor-Local Garbage Collection

Garbage collection was another source of interference between Ractors.
Previously, a global collection cycle could stop all Ractors, meaning that one Ractor triggering garbage collection could interrupt otherwise independent workloads.

Ruby 4.1.0-preview1 introduces Ractor-local garbage collection, allowing each Ractor to collect its own heap without stopping the others.

A local collection can also be requested explicitly:
GC.start(global: false)
Global collection is still necessary for certain operations, including managing shareable objects and reclaiming the heaps of terminated Ractors.

This is particularly relevant for allocation-heavy workloads, where independent collection cycles can reduce the time Ractors spend waiting on each other.
Global GC pauses every Ractor; Ractor-local GC lets each Ractor collect its own heap independently.
Global GC pauses every Ractor; Ractor-local GC lets each Ractor collect its own heap independently.

What This Means for Your Rails App

Most of this work happens inside Ruby itself, so your application can benefit from it without code changes. In practice:
  • Enable YJIT now. It is on by default in apps using Rails 7.2+ defaults on Ruby 3.3+. Apps upgraded from older Rails versions need config.yjit = true, or you can start Ruby with --yjit or set RUBY_YJIT_ENABLE=1.
  • Try ZJIT on staging only. On a Ruby 4.0+ build with ZJIT enabled, run with --zjit and benchmark it against YJIT on your own workload. Shopify's results come from one large application, and yours may behave differently.
  • Treat Ractors as experimental. Gem compatibility is the main obstacle: many gems rely on shared mutable state that Ractors do not allow.
Trying ZJIT means getting to Ruby 4.x first. If your app is stuck on an older Ruby or Rails version, our Ruby on Rails upgrade services can get you there safely. For new features and long-term work on your app, see our Ruby on Rails development services.

For more ways to speed up a Rails application, read 18 Tools and Techniques to Improve Rails Application Performance and our Rails Optimization Guide.

FAQ

Is ZJIT faster than YJIT?

Not across the board yet. In Shopify's early October 2026 rollout, ZJIT regions served requests about as fast as YJIT regions while using about 19% less JIT memory, though this was not a controlled benchmark and some benchmarks were still slower.

Should I use ZJIT in production?

Not yet for most applications. ZJIT is experimental in Ruby 4.0. Test it on staging with --zjit and compare it with YJIT on your own workload before considering production.

Do Ractors remove the GVL?

No. CRuby still has a GVL, but each Ractor has its own, so code in different Ractors can run in parallel on separate CPU cores. Threads inside the same Ractor still share one GVL.

How do I enable YJIT in Rails?

On Ruby 3.3+, apps using Rails 7.2+ defaults have YJIT enabled automatically. Apps upgraded from older Rails versions can set config.yjit = true. You can also start Ruby with --yjit or set the RUBY_YJIT_ENABLE=1 environment variable.
Share: