Skip to content

Commit ebcefc1

Browse files
committed
Make a CLI option for disabling benchmark-mode
1 parent 16d0c97 commit ebcefc1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

misc/benchmark_mode.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def list_to_ints(list)
2121
class << self
2222
# Enable all available settings.
2323
def engage!(nice: nil)
24+
# Set scheduler priority ("niceness") for this process (and any child processes).
2425
Nice.renice_process_group!(nice || -15, Process.getpgrp)
2526

2627
return unless bench_cpus = find_bench_cpus

run_benchmarks.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def have_yjit?(ruby)
5959
end
6060

6161
# Disable Turbo Boost while running benchmarks. Maximize the CPU frequency.
62-
def set_bench_config(turbo:)
62+
def set_bench_config(turbo:, benchmark_mode:)
6363
# sudo requires the flag '-S' in order to take input from stdin
6464
if File.exist?('/sys/devices/system/cpu/intel_pstate') # Intel
6565
unless intel_no_turbo? || turbo
@@ -76,7 +76,7 @@ def set_bench_config(turbo:)
7676
check_call("sudo -S cpupower frequency-set -g performance") unless performance_governor?
7777
end
7878

79-
if os == :linux && ENV["BENCHMARK_MODE"] != '0'
79+
if os == :linux && benchmark_mode
8080
BenchmarkMode.engage!&.then do |cpu|
8181
ENV["YJIT_BENCH_CPU"] = cpu.to_s
8282
end
@@ -330,6 +330,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
330330
name_filters: [],
331331
rss: false,
332332
graph: false,
333+
benchmark_mode: true,
333334
no_pinning: false,
334335
turbo: false,
335336
})
@@ -423,6 +424,10 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
423424
args.graph = true
424425
end
425426

427+
opts.on("--no-benchmark-mode", "Disable cpusets, niceness, hyper-threading toggling") do
428+
args.benchmark_mode = false
429+
end
430+
426431
opts.on("--no-pinning", "don't pin ruby to a specific CPU core") do
427432
args.no_pinning = true
428433
end
@@ -447,8 +452,8 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
447452
end
448453
end
449454

450-
# Disable CPU frequency scaling
451-
set_bench_config(turbo: args.turbo)
455+
# Disable CPU frequency scaling, enable cpusets, etc
456+
set_bench_config(turbo: args.turbo, benchmark_mode: args.benchmark_mode)
452457

453458
# Check pstate status
454459
check_pstate(turbo: args.turbo)

0 commit comments

Comments
 (0)