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

Print YJIT code size besides RSS #319

Merged
merged 2 commits into from
Aug 19, 2024
Merged

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Aug 15, 2024

This PR prints YJIT's memory-related stats besides RSS after each run of a benchmark.

When we check the YJIT code size on yjit-bench, we often use --yjit-stats and look at what it prints. However, because --yjit-stats generates more code than --yjit, it has some unwanted noise. To check the actual code size, we need to look at RubyVM::YJIT.runtime_stats without using --yjit, and this PR lets the harness do that.

Example:

$ ./run_benchmarks.rb lobsters --chruby 'ruby --yjit' --once
Running benchmark "lobsters" (1/1)
setarch x86_64 -R taskset -c 19 /opt/rubies/ruby/bin/ruby --yjit -I harness /home/k0kubun/src/github.com/Shopify/yjit-bench/benchmarks/lobsters/benchmark.rb
ruby 3.4.0dev (2024-08-15T17:34:25Z master de28ef7db4) +YJIT [x86_64-linux]
Command: bundle check 2> /dev/null || bundle install
The Gemfile's dependencies are satisfied
itr #1: 2779ms
RSS: 291.4MiB
MAXRSS: 291.4MiB
inline_code_size:    3,308,526
outlined_code_size:  2,873,627
code_region_size:    7,946,240
yjit_alloc_size:    18,478,455
Total time spent benchmarking: 9s

ruby: ruby 3.4.0dev (2024-08-15T17:34:25Z master de28ef7db4) +YJIT [x86_64-linux]

--------  ---------  ----------
bench     ruby (ms)  stddev (%)
lobsters  2779.7     0.0
--------  ---------  ----------

Output:
./data/output_1567.csv

@k0kubun k0kubun requested a review from a team August 15, 2024 20:28
Copy link
Contributor

@rwstauner rwstauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

puts "code_region_size: #{formatted_stats[:code_region_size]}"
puts "yjit_alloc_size: #{formatted_stats[:yjit_alloc_size]}"

if RubyVM::YJIT.stats_enabled?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to just include this all the time?
It's only a small amount of extra data, but as long as we have it why not keep it?

Copy link
Member Author

@k0kubun k0kubun Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think it's fine. I don't personally use the JSON file, so I just didn't care to change anything in it. Fixed it to include them cc5c815

Copy link
Contributor

@rwstauner rwstauner Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@k0kubun k0kubun merged commit 59b7f86 into Shopify:main Aug 19, 2024
4 checks passed
@k0kubun k0kubun deleted the yjit-code-size branch August 19, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants