I wonder if there's a way to add some Rust into MRI. Perhaps someone could write a YARV VM or a version of the JIT in Rust. It'd complicate the build pipeline, but it'd be iterative and improve the main implementation of Ruby.
I wonder if there's a way to add some Rust into MRI. Perhaps someone could write a YARV VM or a version of the JIT in Rust. It'd complicate the build pipeline, but it'd be iterative and improve the main implementation of Ruby.
Ruby has a great black box testing suite called ruby/spec [0] that is shared among multiple Ruby implementations. Artichoke has a custom runner [1] to track progress on implementation completeness.
If Artichoke passes ruby/spec and is not compatible with MRI, that's a bug in the specs.
re: adding Rust to MRI, I'm working on extracting the mruby backend from the core VM infra + core/stdlib impls [3] which would let us use MRI as the backing VM via rutie. When the Artichoke core and stdlib is complete, this would mean that the MRI runtime could be implemented entirely in Rust [2].
[0] https://github.com/ruby/spec [1] https://github.com/artichoke/artichoke/tree/master/spec-runn... [2] https://github.com/artichoke/artichoke/issues/92 [3] https://artichoke.github.io/artichoke/artichoke_core/
OTOH, I'm sure there are such bugs where the specs don't cover every corner-case behavior. Specs are added when finding bugs in alternative implementations and following MRI's NEWS for new features, but there is no guarantee specs are complete.
One spec I know is missing is how capture groups should not be expanded into globals on `String#=~`. I'll file an issue [0].
^[1] https://github.com/codicoscepticos/ruby-implementations
If you can run mspec at all then that’s pretty good to be honest.
I've implemented a runner that can skip known things that cause the spec to hang (e.g. Mutex specs since Artichoke has a single-threaded implementation of Mutex that deadlocks during the specs).
$ pushd spec-runner/vendor/ruby/language
$ cargo run --bin spec-runner **/*.rb
Passed 1078, skipped 35, not implemented 2, failed 476 specs.
$ popd; pushd spec-runner/vendor/ruby/core
$ cargo run --bin spec-runner **/*.rb
Passed 5412, skipped 998, not implemented 201, failed 8629 specs.
$ popd; pushd spec-runner/vendor/ruby/library
$ cargo run --bin spec-runner **/*.rb
Passed 0, skipped 22, not implemented 16, failed 3276 specs.
The library specs pass number is a bug in my spec runner. All packages added to Artichoke pass ruby/spec. Those packages are : delegate, forwardable, json, monitor, ostruct, set, srscan, and uri.I'm building a tracing JIT for CRuby in Rust at the moment. I started out trying to build a method JIT but mixing type analysis and iterative inlining to deal with real idiomatic Ruby code gets complex very fast. With tracing, both follow naturally.
If I remember correctly there was a Tracing JIT for CRuby in 2016, but discontinued due to memory consumption
[1] https://bugs.ruby-lang.org/issues/12589 [2] https://medium.com/@k0kubun/the-method-jit-compiler-for-ruby... [3] https://www.youtube.com/watch?v=emhYoI_RiOA
Light weight JIT only helps to remove the overhead of GCC etc. Not to be able to inline, constant fold etc. Something like the JRuby IR is required for that.
In LuaJIT the FFI specifies enough type information to be able to call native functions from a trace.
I’m targeting optimizing through ActiveSupport String.blank? now I’ve got some micro benchmarks running.
Aaron Patterson spoke to this in a recent interview. In fact I think he specifically mentioned using Rust as a possibility for a JIT