Project

General

Profile

Actions

Feature #18440

open

YJIT is enabled if any YJIT tuning options are set

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

Status:
Open
Priority:
Normal
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) 11 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) 11 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) 11 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)) {
#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) 11 months 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) 11 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0