Skip to content

Conversation

dorkrawk
Copy link
Contributor

This change refactors the gen_opt_mod function in YJIT to more closely match the style of similar functions and reduce the number of side exits (gen_opt_mod is one of the top 20 exits in this most recent YJIT metric report).

Most of these exits were caused by the situation where % is used for String interpolation.

As part of this change we also call rb_fix_mod_fix directly rather than calling it through rb_vm_opt_mod, moving the % 0 check into the gen_opt_mod function.

Before the change:

./miniruby --disable-gems --yjit-stats -e '1000.times { "%i" % 456 }'

ratio_in_yjit:              36.4%
Top-20 most frequent exit ops (100.0% of exits):
                 opt_mod:        991 (100.0%)


./miniruby --disable-gems --yjit-stats -e '1000.times { 123 % 456 }'
-----8<-----
ratio_in_yjit:              89.1%
Top-20 most frequent exit ops (0% of exits):

After the change:

./miniruby --disable-gems --yjit-stats -e '1000.times { "%i" % 456 }'

ratio_in_yjit:              90.9%
Top-20 most frequent exit ops (100.0% of exits):
                opt_mod:          1 (100.0%)


./miniruby --disable-gems --yjit-stats -e '1000.times { 123 % 456 }'

ratio_in_yjit:              91.1%
Top-20 most frequent exit ops (NaN% of exits):

@maximecb maximecb merged commit b6f6fc6 into ruby:master Jun 30, 2022
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