Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions run_benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ def have_yjit?(ruby)
ruby_version.downcase.include?("yjit")
end

def set_bench_config
def set_bench_config(turbo:)
if File.exist?('/sys/devices/system/cpu/intel_pstate') # Intel
# sudo requires the flag '-S' in order to take input from stdin
check_call("sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'") unless intel_no_turbo?
check_call("sudo -S sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'") unless turbo || intel_no_turbo?
check_call("sudo -S sh -c 'echo 100 > /sys/devices/system/cpu/intel_pstate/min_perf_pct'") unless intel_perf_100pct?
elsif File.exist?('/sys/devices/system/cpu/cpufreq/boost') # AMD
check_call("sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'") unless amd_no_boost?
check_call("sudo -S sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'") unless turbo || amd_no_boost?
check_call("sudo -S cpupower frequency-set -g performance") unless performance_governor?
end
end

def check_pstate
def check_pstate(turbo:)
if File.exist?('/sys/devices/system/cpu/intel_pstate') # Intel
unless intel_no_turbo?
unless turbo || intel_no_turbo?
puts("You forgot to disable turbo:")
puts(" sudo sh -c 'echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo'")
exit(-1)
Expand All @@ -82,7 +82,7 @@ def check_pstate
exit(-1)
end
elsif File.exist?('/sys/devices/system/cpu/cpufreq/boost') # AMD
unless amd_no_boost?
unless turbo || amd_no_boost?
puts("You forgot to disable boost:")
puts(" sudo sh -c 'echo 0 > /sys/devices/system/cpu/cpufreq/boost'")
exit(-1)
Expand Down Expand Up @@ -309,6 +309,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
rss: false,
graph: false,
no_pinning: false,
turbo: false,
})

OptionParser.new do |opts|
Expand Down Expand Up @@ -398,6 +399,10 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
opts.on("--no-pinning", "don't pin ruby to a specific CPU core") do
args.no_pinning = true
end

opts.on("--turbo", "don't disable CPU turbo boost") do
args.turbo = true
end
end.parse!

# Remaining arguments are treated as benchmark name filters
Expand All @@ -416,10 +421,10 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
end

# Disable CPU frequency scaling
set_bench_config
set_bench_config(turbo: args.turbo)

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

# Create the output directory
FileUtils.mkdir_p(args.out_path)
Expand Down