Project

General

Profile

Actions

Feature #18440

closed

YJIT is enabled if any YJIT tuning options are set

Added by georgeclaghorn (George Claghorn) over 2 years ago. Updated 8 months ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:106836]

Description

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'
nil

$ 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) over 2 years 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) over 2 years 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) over 2 years 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)) {
#if USE_MJIT
                FEATURE_SET(opt->features, FEATURE_BIT(yjit));
#else
                rb_warn("Ruby was built without JIT support");
#endif
            }

Updated by k0kubun (Takashi Kokubun) over 2 years ago

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

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) over 2 years 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.

Actions #6

Updated by k0kubun (Takashi Kokubun) 8 months ago

  • Status changed from Open to Feedback

Updated by byroot (Jean Boussier) 8 months ago

For what it's worth, I would expect --yjit-* options not to turn on YJIT. I agree that it's surprising, I would expect only --yjit or RUBY_YJIT_ENABLE=1 to actually enable it.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0