rvm
rvm copied to clipboard
Add support for ruby-yjit
Description
Support the experimental YJIT branch from Shopify: https://shopify.engineering/yjit-faster-rubying.
It is currently available on ruby-build: https://github.com/rbenv/ruby-build/blob/9d3992be66ce10d4367cdf63923930384c78a771/share/ruby-build/yjit-dev
We would welcome a PR for this feature...
I don't think there's a need for a separate entry.
1/ it's going to be merged to the main repository very soon, after that, you'll be able to test it with rvm install ruby-head
see https://github.com/ruby/ruby/pull/4992
2/ or you can use a custom remote repository
rvm install ruby-head-yjit --branch main --url https://github.com/Shopify/yjit.git
Depends if you want bleeding edge YJIT or not. We'll continue our development in Shopify/yjit and the upstream will be a bit more stable.
maybe provide an easy option to have both install for easy switching and testing ?
I guess, the only thing you have to do is to make sure you have rust installed brew install rust
and then rvm install 3.2.0 --reconfigure --enable-yjit
.
has this changed for Ruby 3.2 ?
with 3.1, its enabled by default as far as compilation goes.
you need to set an ENV var to true, RUBY_YJIT_ENABLE
Shell/Bash
export RUBY_YJIT_ENABLE=true
Docker
ENV RUBY_YJIT_ENABLE true
hmm, to clarify @mathieujobin, you need to set those vars when compiling Ruby 3.2.0 from source, right? Maybe I'm missing something, but YJIT was not enabled for me when I build 3.2.0 🤔
at runtime...
$ ruby -e 'puts RUBY_DESCRIPTION'
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux]
$ RUBY_YJIT_ENABLE=true ruby -e 'puts RUBY_DESCRIPTION'
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) +YJIT [x86_64-linux]
$ ruby -e 'puts RUBY_DESCRIPTION'
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
$ RUBY_YJIT_ENABLE=true ruby -e 'puts RUBY_DESCRIPTION'
ruby 3.2.0 (2022-12-25 revision a528908271) +YJIT [x86_64-linux]
I did nothing at compile time, just rvm install 3.2
I didn't have it on Debian 11 using the default commands. With @tisba's method of adding --enable-yjit
it worked.
By the way, how do you specify rustc edition explicily?
rvm install 3.2.0 -C "--enable-yjit"
enable you to build with Rust YJIT, but it also causes(rustc 1.63.0+dfsg1-1):
compiling dmyenc.c
building Rust YJIT (release mode)
error: argument for `--edition` must be one of: 2015|2018. (instead was `2021`)
@kenhys this was fixed for me on Debian 11 by installing the latest Rust: https://www.rust-lang.org/tools/install
YJIT performance improvement on Raspberry Pi 4 is super impressive.
@darkBuddha Thanks, it works.
% ruby --yjit -v
ruby 3.2.0 (2022-12-25 revision a528908271) +YJIT [x86_64-linux]
I tried today, and was surprised to find that the binary wasn't compiled with yjit.
15:09 $ rvm install 3.2
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/ubuntu/20.04/x86_64/ruby-3.2.0.tar.bz2
...
15:11 $ ruby --yjit -v
ruby: warning: Ruby was built without YJIT support. You may need to install rustc to build Ruby with YJIT.
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
Is there an alternative binary that rvm can install that has yjit baked in?
As the warning says...
you need rustc
preinstalled
Yes, to compile Ruby with YJIT from source, rust is required. But rust isn't required to run Ruby with YJIT, and rvm prefers to install precompiled binaries when it can. I was expecting that the precompiled 3.2 binaries that rvm is pointing to would have YJIT support compiled in, but it seems they don't. My question is whether it's possible to point to other binaries that do, and perhaps even whether or not this should be considered a bug in rvm, and therefore changed for everyone.
oh, they have resumed building precompiled binaries? That's good news.
I agree with you, the precompiled binaries for 3.1 and 3.2+ should have YJIT support built-in
Any updates on this? Just did rvm install ruby-3.2.1
and was sad to see no YJIT support. Since I'm building a liquid-heavy site, YJIT does speed up my builds considerably...
@buddhist-uni
Does it work if you do export RUBY_CONFIGURE_OPTS="--enable-yjit"
before rvm install
?
Huzzah! Thanks, @maximecb That did it 😺
Bumping because rvm is still not shipping pre-compiled binaries with YJIT enabled. That would be ideal.
Bumping because still not available in prebuilt binaries for 3.3
@botandrose prebuilt binaries is per platform. it might have been enabled for one platform but not the other. Please be more precise which binary is missing YJIT support
@mathieujobin Ah, it looks like the situation has changed!
micah@yupa:~$ rvm install ruby-3.3.0
Found remote file https://rubies.travis-ci.org/ubuntu/22.04/x86_64/ruby-3.3.0.tar.bz2
[snip]
micah@yupa:~$ ruby --yjit -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-linux]
Very happy to see this!