Skip to content

Commit eb178d1

Browse files
committed
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 "$@"' - "$@"
1 parent e73823e commit eb178d1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎lib/benchmark_suite.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ def linux?
230230

231231
# Set up the base command with CPU pinning if needed
232232
def base_cmd(ruby_description, benchmark_name)
233+
ENV["RUBY_BENCH_PREFIX_COMMAND"]&.tap do |var|
234+
return [var] if var
235+
end
236+
233237
if linux?
234238
cmd = setarch_prefix
235239

0 commit comments

Comments
 (0)