ZJIT is now available in Ruby 4.0
4 months ago
- #JIT
- #Compiler
- #Ruby
- ZJIT is a new JIT compiler for Ruby 4.0, built by the same team behind YJIT.
- ZJIT is compiled by default in Ruby 4.0 but needs to be enabled via flags or environment variables.
- ZJIT currently performs better than the Ruby interpreter but not as fast as YJIT.
- The compiler now supports side-exits, allowing JIT code to transition back to the interpreter when needed.
- ZJIT can now handle a broader range of Ruby code, including full test suites for major applications.
- Optimizations now cover more operations, including method sends, instance variables, and constant folding.
- ZJIT can compile large functions efficiently and has improved handling of C methods.
- The team has grown, with more contributors from the community.
- A graph visualization tool has been integrated to help debug and optimize ZJIT.
- Future plans include optimizing invokeblock and invokesuper, polymorphic sends, and improving register allocation.
- Performance metrics show steady improvements, with benchmarks available on rubybench.
- Users are encouraged to test ZJIT but advised against production use due to potential instability.
- YJIT remains the default JIT compiler in Ruby 4.0, but ZJIT is a significant step forward.