From eb178d143af30903cdaf9c2da73e277edaf195fd Mon Sep 17 00:00:00 2001 From: Randy Stauner Date: Tue, 7 Jul 2026 13:39:19 -0700 Subject: [PATCH] Enable custom prefix command from env var I setup my machine with the kernel options to isolate a cpu and then I have a custom script that writes to the necessary files, and I have NOPASSWD sudo commands setup for the commands in that file. Then I can set this env var to that script and it runs benchmarks specifically configured for my machine with no sudo prompt. Example script: #!/bin/bash # sudoers # rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/intel_pstate/no_turbo # rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/intel_pstate/min_perf_pct # rwstauner ALL= NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/cpu*/online # rwstauner ALL= NOPASSWD: /usr/bin/renice # NOTE: add `isolcpus=10,11 nohz_full=10,11` to the options line in /boot/loader conf cpu=10 sibling=11 sudo () { command sudo --bell "$@" } teardown () { echo 0 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo echo 8 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct echo 1 | sudo tee /sys/devices/system/cpu/cpu$sibling/online } setup () { echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo echo 100 | sudo tee /sys/devices/system/cpu/intel_pstate/min_perf_pct echo 0 | sudo tee /sys/devices/system/cpu/cpu$sibling/online } setup > /dev/null trap 'teardown > /dev/null' EXIT setarch x86_64 -R taskset -c $cpu sh -c 'sudo renice -n -15 "$$" > /dev/null; exec "$@"' - "$@" --- lib/benchmark_suite.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/benchmark_suite.rb b/lib/benchmark_suite.rb index ce37d2f1..10343f36 100644 --- a/lib/benchmark_suite.rb +++ b/lib/benchmark_suite.rb @@ -230,6 +230,10 @@ def linux? # Set up the base command with CPU pinning if needed def base_cmd(ruby_description, benchmark_name) + ENV["RUBY_BENCH_PREFIX_COMMAND"]&.tap do |var| + return [var] if var + end + if linux? cmd = setarch_prefix