Skip to content

Commit 338466a

Browse files
committed
Integrate debug counters
If we compile ruby with debug counters and use that ruby for running yjit-bench, there's a mess of output due to the ruby subprocesses that get run (ex: `bundle install`). This is because by default, the output is shown at ruby exit. This change adds a new option `--show-debug-counters` that disables all debug counter output for everything except the benchmark scripts. The counters get reset before each benchmark script is run so that the counters during ruby initialization and prelude are not taken into account.
1 parent 997782a commit 338466a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

harness/harness-common.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ def return_results(warmup_iterations, bench_iterations)
153153
end
154154

155155
write_json_file(yjit_bench_results)
156+
157+
if ENV["YJIT_BENCH_SHOW_DEBUG_COUNTERS"]=="1"
158+
ENV["RUBY_DEBUG_COUNTER_DISABLE"] = "0"
159+
RubyVM.show_debug_counters if defined?(RubyVM.show_debug_counters)
160+
ENV["RUBY_DEBUG_COUNTER_DISABLE"] = "1"
161+
end
156162
end
157163

158164
def write_json_file(yjit_bench_results)

harness/harness.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def run_benchmark(_num_itrs_hint, &block)
3939
header = "itr: time"
4040

4141
RubyVM::YJIT.reset_stats! if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
42+
RubyVM.reset_debug_counters if defined?(RubyVM.reset_debug_counters)
4243

4344
# If $YJIT_BENCH_STATS is given, print the diff of these stats at each iteration.
4445
if ENV["YJIT_BENCH_STATS"]

run_benchmarks.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ def run_benchmarks(ruby:, ruby_description:, categories:, name_filters:, out_pat
420420
opts.on("--turbo", "don't disable CPU turbo boost") do
421421
args.turbo = true
422422
end
423+
424+
opts.on("--show-debug-counters", "Show debug counters (if available) after each benchmark has run") do
425+
# disable showing debug counters for any subprocesses of ruby that we run except the benchmark scripts themselves
426+
ENV["RUBY_DEBUG_COUNTER_DISABLE"] = "1"
427+
ENV["YJIT_BENCH_SHOW_DEBUG_COUNTERS"] = "1"
428+
end
423429
end.parse!
424430

425431
# Remaining arguments are treated as benchmark name filters

0 commit comments

Comments
 (0)