From d138ff83e4bcd1d1393efa1b3e36c250e784abff Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 11 Feb 2026 16:41:43 -0800 Subject: [PATCH] Add --no-sudo option to skip all operations that require sudo When running benchmarks on machines without sudo access, the CPU configuration (turbo boost, min_perf_pct, frequency governor) cannot be set or verified. The --no-sudo flag skips the entire CPUConfig setup, which includes both the sudo-dependent writes and the checks that exit when the expected configuration isn't detected. --- lib/argument_parser.rb | 6 ++++++ lib/benchmark_runner/cli.rb | 2 +- test/argument_parser_test.rb | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/argument_parser.rb b/lib/argument_parser.rb index f820a669..36c2186a 100644 --- a/lib/argument_parser.rb +++ b/lib/argument_parser.rb @@ -19,6 +19,7 @@ class ArgumentParser :no_pinning, :force_pinning, :turbo, + :no_sudo, :skip_yjit, :skip_zjit, :with_pre_init, @@ -158,6 +159,10 @@ def parse(argv) opts.on("--turbo", "don't disable CPU turbo boost") do args.turbo = true end + + opts.on("--no-sudo", "skip all operations that require sudo") do + args.no_sudo = true + end end.parse!(argv) # Remaining arguments are treated as benchmark name filters @@ -223,6 +228,7 @@ def default_args no_pinning: false, force_pinning: false, turbo: false, + no_sudo: false, skip_yjit: false, skip_zjit: true, with_pre_init: nil, diff --git a/lib/benchmark_runner/cli.rb b/lib/benchmark_runner/cli.rb index d4c011c2..f73e3ea9 100644 --- a/lib/benchmark_runner/cli.rb +++ b/lib/benchmark_runner/cli.rb @@ -21,7 +21,7 @@ def initialize(args) end def run - CPUConfig.configure_for_benchmarking(turbo: args.turbo) + CPUConfig.configure_for_benchmarking(turbo: args.turbo) unless args.no_sudo # Create the output directory FileUtils.mkdir_p(args.out_path) diff --git a/test/argument_parser_test.rb b/test/argument_parser_test.rb index d19ae240..3c49f560 100644 --- a/test/argument_parser_test.rb +++ b/test/argument_parser_test.rb @@ -52,6 +52,7 @@ def setup_mock_ruby(path) assert_equal false, args.graph assert_equal false, args.no_pinning assert_equal false, args.turbo + assert_equal false, args.no_sudo assert_equal false, args.skip_yjit end end @@ -454,6 +455,15 @@ def setup_mock_ruby(path) end end + describe '--no-sudo option' do + it 'sets no_sudo flag' do + parser = ArgumentParser.new + args = parser.parse(['--no-sudo']) + + assert_equal true, args.no_sudo + end + end + describe 'remaining arguments' do it 'treats remaining arguments as name filters' do parser = ArgumentParser.new