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

YJIT: port call threshold logic from Rust to C for performance #8628

Merged
merged 6 commits into from
Oct 12, 2023

Conversation

maximecb
Copy link
Contributor

@maximecb maximecb commented Oct 11, 2023

This way the C compiler can potentially inline the YJIT call threshold logic, and we avoid allocating/touching the ISEQ payload object or needing to take the VM lock to do call threshold accounting.

@matzbot matzbot requested a review from a team October 11, 2023 18:02
@k0kubun
Copy link
Member

k0kubun commented Oct 11, 2023

Benchmarked this with --yjit-cold-threshold=0 and fib (since the result of 30k_methods was unreliable for some reason 🤔). It's looking good.

before: ruby 3.3.0dev (2023-10-11T14:16:39Z master cc311e1c45) +YJIT [x86_64-linux]
last_commit=[ruby/irb] Avoid locking the debug UI to a single thread (https://github.com/ruby/irb/pull/725)
after: ruby 3.3.0dev (2023-10-11T21:16:38Z yjit_c_threshold_l.. ba3587b89d) +YJIT [x86_64-linux]
last_commit=Exclude yjit_calls_at_interv from RJIT bindgen

-----  -----------  ----------  ----------  ----------  -------------  ------------
bench  before (ms)  stddev (%)  after (ms)  stddev (%)  after 1st itr  before/after
fib    237.9        0.1         226.7       0.2         1.06           1.05
-----  -----------  ----------  ----------  ----------  -------------  ------------

@maximecb
Copy link
Contributor Author

maximecb commented Oct 11, 2023

Oh wow, that much speed difference! I'm surprised, but seems it was really worth it!

We should expose rb_yjit_compile_new_iseqs() as a Rust-side global next 🤔

@maximecb maximecb merged commit b2e1ddf into ruby:master Oct 12, 2023
94 checks passed
@maximecb maximecb deleted the yjit_c_threshold_logic branch October 12, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants