TL;DR
ZJIT, a new just-in-time compiler for Ruby's reference VM (YARV), is included in Ruby 4.0 as compiled-by-default but disabled unless explicitly enabled. It already beats the interpreter in many workloads but does not yet match YJIT; the team recommends experimenting locally and reporting issues rather than deploying to production immediately.
What happened
The ZJIT team has integrated a new method-oriented JIT into the reference Ruby implementation (YARV) and merged it for Ruby 4.0. ZJIT is compiled into the runtime by default but remains disabled; users can turn it on with –zjit, the RUBY_ZJIT_ENABLE environment variable, or RubyVM::ZJIT.enable. Since its earlier announcement, the compiler gained critical features: side-exit support to fall back to the interpreter on guards, wider optimization coverage (method sends, instance variable access, allocations, certain string ops, optional parameters and more), inlining borrowed from YJIT, and a small C-method inliner for well-known runtime functions. The team reduced calls from generated code into CRuby by open-coding several operations, fixed register spilling so very large functions compile, and report sub-millisecond compile times for large methods. ZJIT now runs a wide range of workloads — including the full Ruby test suite and large application test traffic — but the project remains under active development with known instability risks.
Why it matters
- Provides a new compiler foundation that aims to raise Ruby's performance ceiling by using larger compilation units and an SSA-style IR.
- Moves the reference implementation toward a more traditional method compiler, which the team hopes will lower barriers for external contributors.
- Already enables running a much broader set of real-world code than earlier ZJIT snapshots, including full test suites and large-app traffic.
- Because the compiler is new and can cause crashes or regressions, the change has immediate operational implications for testing and deployment practices.
Key facts
- ZJIT is compiled into Ruby 4.0 by default but is not enabled by default.
- Enable it via the –zjit flag, RUBY_ZJIT_ENABLE environment variable, or RubyVM::ZJIT.enable at runtime.
- ZJIT is faster than the interpreter in many cases but not yet as fast as YJIT according to the team.
- The compiler gained side-exit support, allowing JIT code to transfer control back to the interpreter when guards fail.
- ZJIT now runs the full Ruby test suite, the test suite and shadow traffic of a large Shopify application, and GitHub.com’s test suite.
- Optimizations implemented include method send specialization, instance variable reads/writes, attribute accessors, struct accesses, allocations, certain string ops, and optional parameters.
- A limited inliner and a C-method inliner let the optimizer treat some built-in C methods as inline HIR sequences (example: Integer#succ).
- The backend was improved to avoid frequent C runtime calls from generated code by open-coding many operations.
- The team fixed register spilling issues, enabling compilation of very large functions, often in under a millisecond.
What to watch next
- Optimization of invokeblock (yield) and invokesuper (super) instructions — common patterns that behave like sends.
- Improvements to setinstancevariable when object shapes change (affects @a = b and patterns like @a ||= b).
- Support for polymorphic sends and the ongoing rewrite of the register allocator to unlock more optimizations.
- Better handling of phase changes (using side-exit profiles to trigger recompilation) and deferring writes to the VM frame to reduce VM traffic.
Quick glossary
- JIT (Just-In-Time) compiler: A compiler that generates machine code at runtime for parts of a program to improve performance compared with interpretation.
- YARV: The reference Ruby virtual machine that executes Ruby bytecode; stands for Yet Another Ruby VM.
- YJIT: An existing JIT compiler for Ruby that influenced parts of ZJIT’s design and implementation.
- Side-exit: A mechanism where JIT-generated code transfers control back to the interpreter when assumptions or guards fail.
- SSA (Static Single Assignment) IR: An intermediate representation where each variable is assigned exactly once, used to enable optimizations.
Reader FAQ
How do I enable ZJIT in Ruby 4.0?
Use the –zjit command-line flag, set RUBY_ZJIT_ENABLE in the environment, or call RubyVM::ZJIT.enable after startup.
Is ZJIT ready for production?
The team advises caution: ZJIT can cause crashes or large regressions and should be tested thoroughly before any production deployment.
How does ZJIT perform compared with other runtimes?
ZJIT is already faster than the interpreter in many benchmarks but has not yet matched YJIT; the team is working on further optimizations.
Who developed ZJIT and where can I report issues?
A group of developers including Aaron Patterson, Aiden Fox Ivey, Alan Wu and others worked on ZJIT; issues can be reported on the Ruby issue tracker or on GitHub.

ZJIT is now available in Ruby 4.0 2025-12-24 • Max Bernstein ZJIT is a new just-in-time (JIT) Ruby compiler built into the reference Ruby implementation, YARV, by the same compiler…
Sources
- ZJIT is now available in Ruby 4.0
- Ruby 4.0.0 Released
- What Is New In Ruby 4.0
- Ruby Turns 30: A Celebration of Code, Community, and …
Related posts
- How to Embed Files in C/C++ Binaries: Tools, Preprocessor, and ASM
- C/C++ Embedded Files: Methods to Include Resource Data Inside Binaries
- Xcc700 — a 700-line self-hosting C compiler for ESP32/Xtensa