Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit YJIT stats to the measured benchmark code #352

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions harness/harness-common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,17 @@ def return_results(warmup_iterations, bench_iterations)
"bench" => bench_iterations,
}

# Collect yjit stats before loading any additional code.
yjit_stats = RubyVM::YJIT.runtime_stats if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?

# Collect our own peak mem usage as soon as reasonable after finishing the last iteration.
rss = get_rss
yjit_bench_results["rss"] = rss
if maxrss = get_maxrss
yjit_bench_results["maxrss"] = maxrss
end

if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
yjit_stats = RubyVM::YJIT.runtime_stats
if yjit_stats
yjit_bench_results["yjit_stats"] = yjit_stats

formatted_stats = proc { |key| "%10s" % yjit_stats[key].to_s.reverse.scan(/\d{1,3}/).join(",").reverse }
Expand Down
2 changes: 2 additions & 0 deletions harness/harness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def run_benchmark(_num_itrs_hint, &block)
num_itrs = 0
header = "itr: time"

RubyVM::YJIT.reset_stats! if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?

# If $YJIT_BENCH_STATS is given, print the diff of these stats at each iteration.
if ENV["YJIT_BENCH_STATS"]
yjit_stats = ENV["YJIT_BENCH_STATS"].split(",").map { |key| [key.to_sym, nil] }.to_h
Expand Down
Loading