-
Notifications
You must be signed in to change notification settings - Fork 5.4k
YJIT: Replace Array#each only when YJIT is enabled #11955
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 10000 privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b67e1c3
to
e045b6b
Compare
e045b6b
to
192faf1
Compare
2c561a7
to
b66caef
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure that once the Ruby implementation is subbed in, it's still a basic method, because we have code like the following for example in Enumerable#inject:
if (iter == inject_op_i &&
SYMBOL_P(op) &&
RB_TYPE_P(obj, T_ARRAY) &&
rb_method_basic_definition_p(CLASS_OF(obj), id_each)) {
return ary_inject_op(obj, init, op);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we are likely to port more runtime methods to Ruby (bring back Aaron's ports and add some more?), and that this may increase generated code size, I think it would be good to have a command line flag (or an environment variable?) so we can turn this on or off. This would allow us to test the impact on benchmarks and in production at various stages.
An environment variable might be easier for production?
I was so confused by the
Fixed in d06ac2b
Added |
Good work Kokubun! 👏 |
This PR resurrects the C implementation of
Array#each
for the interpreter and lets YJIT use the Ruby one. To minimize incompatibilities between the interpreter and YJIT, it also introducesPrimitive.attr! :c_trace
to letArray#each
act like a C method in backtraces.It speeds up the interpreter on lobsters a little. While the rewrite of
Array#each
in Ruby #9533 did not slow downArray#each
on the interpreter with microbenchmarks, it had a small impact on larger benchmarks.