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: Fallback megamorphic opt_case_dispatch #9894

Merged
merged 1 commit into from Feb 9, 2024

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Feb 9, 2024

opt_case_dispatch_megamorphic accounts for 68% of exits on rubocop. This PR fixes it by falling back to compile subsequent instructions as is after 20 chains.

This speeds up rubocop by 3%.

before: ruby 3.4.0dev (2024-02-08T23:52:45Z master e2aa00ca66) +YJIT [x86_64-linux]
after: ruby 3.4.0dev (2024-02-08T23:53:29Z yjit-opt-case 2193dc2f13) +YJIT [x86_64-linux]

-------  -----------  ----------  ----------  ----------  -------------  ------------
bench    before (ms)  stddev (%)  after (ms)  stddev (%)  after 1st itr  before/after
rubocop  132.1        4.7         128.0       4.5         0.94           1.03
-------  -----------  ----------  ----------  ----------  -------------  ------------

This also speeds up optcarrot --opt by 17%, which people sometimes use when they compare their JIT against YJIT.

# before
ruby -v --yjit bin/optcarrot-bench --opt
ruby 3.4.0dev (2024-02-08T23:52:45Z master e2aa00ca66) +YJIT [x86_64-linux]
fps: 164.09038383764974

# after
$ ruby -v --yjit bin/optcarrot-bench --opt
ruby 3.4.0dev (2024-02-08T23:53:29Z yjit-opt-case 2193dc2f13) +YJIT [x86_64-linux]
fps: 192.09196646229304

@matzbot matzbot requested a review from a team February 9, 2024 00:02
Copy link
Contributor

@maximecb maximecb left a comment

Choose a reason for hiding this comment

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

Nice work, and thanks for making sure that we deliver on our optcarrot goals! 😆

@maximecb maximecb merged commit 717adb5 into ruby:master Feb 9, 2024
98 checks passed
@k0kubun k0kubun deleted the yjit-opt-case branch February 9, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants