From c838bb0559b367eaf97e2c487da5bf5961220ca1 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Thu, 22 Jan 2026 14:02:55 -0500 Subject: [PATCH 1/3] Add ZJIT to benchmark runner This lets us do some easier side by side perf and memory comparisons with YJIT. --- lib/argument_parser.rb | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/argument_parser.rb b/lib/argument_parser.rb index e7a4cf4e..249c0f50 100644 --- a/lib/argument_parser.rb +++ b/lib/argument_parser.rb @@ -10,6 +10,7 @@ class ArgumentParser :harness, :harness_explicit, :yjit_opts, + :zjit_opts, :categories, :name_filters, :excludes, @@ -19,6 +20,7 @@ class ArgumentParser :force_pinning, :turbo, :skip_yjit, + :skip_zjit, :with_pre_init, keyword_init: true ) @@ -35,7 +37,7 @@ def parse(argv) args = default_args OptionParser.new do |opts| - opts.on("-e=NAME::RUBY_PATH OPTIONS", "ruby executable and options to be benchmarked (default: interp, yjit)") do |v| + opts.on("-e=NAME::RUBY_PATH OPTIONS", "ruby executable and options to be benchmarked (default: interp, yjit, zjit)") do |v| v.split(";").each do |name_executable| name, executable = name_executable.split("::", 2) if executable.nil? @@ -91,6 +93,10 @@ def parse(argv) args.skip_yjit = true end + opts.on("--skip-zjit", "Don't run with zjit after interpreter") do + args.skip_zjit = true + end + opts.on("--harness=HARNESS_DIR", "which harness to use") do |v| v = "harness-#{v}" unless v.start_with?('harness') args.harness = v @@ -124,6 +130,10 @@ def parse(argv) args.yjit_opts = str end + opts.on("--zjit_opts=OPT_STRING", "string of command-line options to run ZJIT with (ignored if you use -e)") do |str| + args.zjit_opts = str + end + opts.on("--with_pre-init=PRE_INIT_FILE", "a file to require before each benchmark run, so settings can be tuned (eg. enable/disable GC compaction)") do |str| args.with_pre_init = str @@ -157,9 +167,16 @@ def parse(argv) # If -e is not specified, benchmark the current Ruby. Compare it with YJIT if available. if args.executables.empty? - if have_yjit?(@ruby_executable) && !args.skip_yjit + use_yjit = have_yjit?(@ruby_executable) && !args.skip_yjit + use_zjit = have_zjit?(@ruby_executable) && !args.skip_zjit + if use_yjit || use_zjit args.executables["interp"] = [@ruby_executable] - args.executables["yjit"] = [@ruby_executable, "--yjit", *args.yjit_opts.shellsplit] + if use_yjit + args.executables["yjit"] = [@ruby_executable, "--yjit", *args.yjit_opts.shellsplit] + end + if use_zjit + args.executables["zjit"] = [@ruby_executable, "--zjit", *args.zjit_opts.shellsplit] + end else args.executables["ruby"] = [@ruby_executable] end @@ -184,6 +201,11 @@ def have_yjit?(ruby) ruby_version.downcase.include?("yjit") end + def have_zjit?(ruby) + ruby_version = `#{ruby} -v --zjit 2> #{File::NULL}`.strip + ruby_version.downcase.include?("zjit") + end + def default_args Args.new( executables: {}, @@ -192,6 +214,7 @@ def default_args harness: "harness", harness_explicit: false, yjit_opts: "", + zjit_opts: "", categories: [], name_filters: [], excludes: [], @@ -201,6 +224,7 @@ def default_args force_pinning: false, turbo: false, skip_yjit: false, + skip_zjit: false, with_pre_init: nil, ) end From b75255f9b0881f6d13b6c2de142d3c1942979c05 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Thu, 22 Jan 2026 15:03:07 -0800 Subject: [PATCH 2/3] Use snake-case Co-authored-by: Takashi Kokubun --- lib/argument_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/argument_parser.rb b/lib/argument_parser.rb index 249c0f50..e681db43 100644 --- a/lib/argument_parser.rb +++ b/lib/argument_parser.rb @@ -130,7 +130,7 @@ def parse(argv) args.yjit_opts = str end - opts.on("--zjit_opts=OPT_STRING", "string of command-line options to run ZJIT with (ignored if you use -e)") do |str| + opts.on("--zjit-opts=OPT_STRING", "string of command-line options to run ZJIT with (ignored if you use -e)") do |str| args.zjit_opts = str end From 84fe0e24bc4207d66cde440d390b1a8762b743c1 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Fri, 23 Jan 2026 13:16:15 -0500 Subject: [PATCH 3/3] Skip ZJIT for now --- lib/argument_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/argument_parser.rb b/lib/argument_parser.rb index e681db43..94a6eb06 100644 --- a/lib/argument_parser.rb +++ b/lib/argument_parser.rb @@ -224,7 +224,7 @@ def default_args force_pinning: false, turbo: false, skip_yjit: false, - skip_zjit: false, + skip_zjit: true, with_pre_init: nil, ) end