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

Support stats "ratio_in_yjit" #3991

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jethrodaniel
Copy link

Note

Missing some other things in this PR (sig updates, CI updates, etc), but gonna go ahead and put the draft up for discussion.

What does this PR do?

When ruby's extended YJIT stats are available (--yjit-stat), then
we have access to numerous additional stats.

This adds :ratio_in_yjit, which is only present when additional stats
are enabled.

Example:

RUBYOPT='--yjit --yjit-stats=quiet' ruby -e '
  def foo = "a" * 10
  300.times{foo}
  puts "ratio_in_yjit: #{::RubyVM::YJIT.runtime_stats[:ratio_in_yjit]}"
'
ratio_in_yjit: 0.9550806290358625

Motivation:

This should allow for a better understanding of how to tune --yjit-exec-mem-size.

From https://github.com/ruby/ruby/blob/ef084cc8f4958c1b6e4ead99136631bef6d8ddba/doc/yjit/yjit.md?plain=1#L213-L223:

If you start Ruby with --yjit-stats, e.g. using an environment variable RUBYOPT=--yjit-stats,
RubyVM::YJIT.runtime_stats[:ratio_in_yjit] shows the ratio of YJIT-executed instructions in %.
Ideally, ratio_in_yjit should be as large as 99%, and increasing --yjit-exec-mem-size often
helps improving ratio_in_yjit.

Additional Notes:

Fwiw, I directly based this on the previous YJIT PRs, which were very helpful here:

ratio_in_yjit has been available sine 3.3.0: https://github.com/ruby/ruby/blob/caf0d2058aa223515897401ff94e11e1c0671ce0/doc/NEWS/NEWS-3.3.0.md?plain=1#L436

How to test the change?

RUBYOPT="--yjit --yjit-stats=quiet" bundle exec rake spec:yjit

bundle exec rake spec:yjit # skipped

When ruby's extended YJIT stats are available (`--yjit-stat`), then
we have access to numerous additional stats.

This adds `:ratio_in_yjit`, which is only present when additional stats
are enabled.

Example:

```
RUBYOPT='--yjit --yjit-stats=quiet' ruby -e '
  def foo = "a" * 10
  300.times{foo}
  puts "ratio_in_yjit: #{::RubyVM::YJIT.runtime_stats[:ratio_in_yjit]}"
'
ratio_in_yjit: 0.9550806290358625
```

Motivation:

This should allow for better understanding of how to tune `--yjit-exec-mem-size`.

From https://github.com/ruby/ruby/blob/ef084cc8f4958c1b6e4ead99136631bef6d8ddba/doc/yjit/yjit.md?plain=1#L213-L223:

> If you start Ruby with `--yjit-stats`, e.g. using an environment variable `RUBYOPT=--yjit-stats`,
> `RubyVM::YJIT.runtime_stats[:ratio_in_yjit]` shows the ratio of YJIT-executed instructions in %.
> Ideally, `ratio_in_yjit` should be as large as 99%, and increasing `--yjit-exec-mem-size` often
> helps improving `ratio_in_yjit`.

How to test the change?:

```
RUBYOPT="--yjit --yjit-stats=quiet" bundle exec rake spec:yjit

bundle exec rake spec:yjit # skipped
```
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.

Project coverage is 97.85%. Comparing base (58b17f0) to head (ea2f656).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
spec/datadog/core/runtime/metrics_spec.rb 44.44% 5 Missing ⚠️
lib/datadog/core/environment/yjit.rb 75.00% 1 Missing ⚠️
lib/datadog/core/runtime/metrics.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3991      +/-   ##
==========================================
- Coverage   97.87%   97.85%   -0.02%     
==========================================
  Files        1314     1314              
  Lines       78652    78667      +15     
  Branches     3909     3912       +3     
==========================================
+ Hits        76978    76980       +2     
- Misses       1674     1687      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants