Skip to content

Commit c43e6f4

Browse files
committed
Only use setarch command if it can be used successfully
1 parent 884c55d commit c43e6f4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

run_benchmarks.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ def sort_benchmarks(bench_names)
222222
headline_names.sort + other_names.sort + micro_names.sort
223223
end
224224

225+
def setarch_prefix
226+
# Disable address space randomization (for determinism)
227+
prefix = ["setarch", `uname -m`.strip, "-R"]
228+
229+
# Abort if we don't have permission (perhaps in a docker container).
230+
return [] unless system(*prefix, "true")
231+
232+
prefix
233+
end
234+
225235
# Run all the benchmarks and record execution times
226236
def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_path:, harness:, pre_init:, no_pinning:)
227237
bench_data = {}
@@ -255,8 +265,7 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
255265
# Set up the benchmarking command
256266
cmd = []
257267
if os == :linux
258-
# Disable address space randomization (for determinism)
259-
cmd += ["setarch", `uname -m`.strip, "-R"]
268+
cmd += setarch_prefix
260269

261270
# Pin the process to one given core to improve caching and reduce variance on CRuby
262271
# Other Rubies need to use multiple cores, e.g., for JIT threads

0 commit comments

Comments
 (0)