Feature #18440


YJIT is enabled if any YJIT tuning options are set

Added by georgeclaghorn (George Claghorn) 5 months ago. Updated 5 months ago.

Target version:


I was testing YJIT in a Rails app with RUBYOPT="--yjit --yjit-exec-mem-size=32". I saw some weird issues around Rails view caching, so I attempted to temporarily disable YJIT by removing --yjit and leaving the tuning options in place (RUBYOPT="--yjit-exec-mem-size=32"). However, YJIT remained enabled until I also removed --yjit-exec-mem-size=32.

$ ruby -e 'puts RubyVM::YJIT.runtime_stats.inspect'

$ ruby --yjit-exec-mem-size -e 'puts RubyVM::YJIT.runtime_stats.inspect'
{:inline_code_size=>378495, :outlined_code_size=>311079}

I expected removing --yjit to disable YJIT and was surprised by this.

Actions #1

Updated by georgeclaghorn (George Claghorn) 5 months ago

  • ruby -v changed from 3.1.0 to ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21]

Updated by georgeclaghorn (George Claghorn) 5 months ago

Sorry, there's a small typo in the example:

$ ruby --yjit-exec-mem-size=32 -e 'puts RubyVM::YJIT.runtime_stats.inspect'
{:inline_code_size=>67775, :outlined_code_size=>52667}

Updated by georgeclaghorn (George Claghorn) 5 months ago

From the code, this appears to be intentional. setup_yjit_options returns true if any of the --yjit-* options are provided:

            else if (strcmp("yjit", s) == 0 || setup_yjit_options(s, &opt->yjit)) {
                FEATURE_SET(opt->features, FEATURE_BIT(yjit));
                rb_warn("Ruby was built without JIT support");

Updated by k0kubun (Takashi Kokubun) 5 months ago

  • Backport deleted (2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN)
  • ruby -v deleted (ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21])
  • Tracker changed from Bug to Feature

From the code, this appears to be intentional.

I think so. At least for MJIT in 2.6~3.0, we used to show:

  --jit           enable JIT with default options (experimental)
  --jit-[option]  enable JIT with an option (experimental)

but we ended up removing it in 3.1 for MJIT and YJIT. Maybe we should add such descriptions again for clarity.

Updated by Eregon (Benoit Daloze) 5 months ago

I think only enabling on explicit --jit/--yjit/--mjit is better because it's more intuitive.
If e.g. --yjit-exec-mem-size=32 is in RUBYOPT it seems unexpected that it would enable YJIT without any --yjit anywhere.


Also available in: Atom PDF