Last December, members of the Ruby JIT team proposed to port the YJIT codebase from C99 to Rust, and while a number of developers had reservations about this, the project was eventually approved by Ruby’s core developers and founder Matz.
Yesterday, the developers responsible for this project said they had completed a Ruby YJIT compiler implemented in Rust that effectively replaces the existing C version and is currently awaiting an upstream merge.
The Rust version of the YJIT compiler is described as having the same level of performance as the C version, as it passes all CRuby tests, is also able to run all YJIT benchmark tests, and performs essentially the same as the C version (it runs in the same way and essentially generates the same machine code). In addition, the development team has added a few design improvements, such as a more fine-grained constant failure mechanism, which is expected to work great in Ruby on Rails applications.
By default, YJIT is not compiled and does not require cargo/rustc. if YJIT is built in dev mode,
cargo is used to fetch development dependencies, but when built in release,
cargo is not required and only
rustc is needed. YJIT currently requires Rust 1.60.0 or later.
It is planned that Rust YJIT will be compiled and included in the system package and compiled binaries for Ruby 3.2. The development team says it doesn’t expect any major issues, as Rust is well supported on every platform YJIT supports.