Skip to content

Commit 9907a8c

Browse files
committed
Use sudo --non-interactive in at_exit to not hang
I noticed that ruby-bench hangs after a long enough benchmarking session. Turns out it was sudo trying to ask for with `quiet: true`. Since it may hang trying to ask for input during exit, let's use `--non-interactive` to opportunistically re-enable turbo boost.
1 parent 7361542 commit 9907a8c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/cpu_config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class IntelCPUConfig < CPUConfig
6767
def disable_turbo_boost
6868
# sudo requires the flag '-S' in order to take input from stdin
6969
BenchmarkRunner.check_call("sudo -S sh -c 'echo #{TURBO_DISABLED_VALUE} > #{NO_TURBO_PATH}'")
70-
at_exit { BenchmarkRunner.check_call("sudo -S sh -c 'echo 0 > #{NO_TURBO_PATH}'", quiet: true) }
70+
at_exit { BenchmarkRunner.check_call("sudo --non-interactive sh -c 'echo 0 > #{NO_TURBO_PATH}'", quiet: true) }
7171
end
7272

7373
def maximize_frequency
@@ -114,7 +114,7 @@ class AMDCPUConfig < CPUConfig
114114
def disable_turbo_boost
115115
# sudo requires the flag '-S' in order to take input from stdin
116116
BenchmarkRunner.check_call("sudo -S sh -c 'echo #{TURBO_DISABLED_VALUE} > #{BOOST_PATH}'")
117-
at_exit { BenchmarkRunner.check_call("sudo -S sh -c 'echo #{TURBO_ENABLED_VALUE} > #{BOOST_PATH}'", quiet: true) }
117+
at_exit { BenchmarkRunner.check_call("sudo --non-interactive sh -c 'echo #{TURBO_ENABLED_VALUE} > #{BOOST_PATH}'", quiet: true) }
118118
end
119119

120120
def maximize_frequency

0 commit comments

Comments
 (0)