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

Add allocation tests for ruby2_keywords #10761

Merged
merged 3 commits into from May 20, 2024

Conversation

jeremyevans
Copy link
Contributor

This tests ruby2_keywords flagged methods, as well as passing ruby2_keywords flagged hashes to other methods.

Some of the behavior here is questionable, such as allocating different numbers of objects depending on whether a block is passed or whether YJIT is enabled. I think there are likely ways to eliminate allocations in certain cases. However, this gives us a baseline and shows us where it is possible to make improvements.

This comment has been minimized.

@jeremyevans jeremyevans force-pushed the ruby2_keywords-allocation-tests branch from e48b043 to d078cfd Compare May 15, 2024 00:44
This tests ruby2_keywords flagged methods, as well as passing
ruby2_keywords flagged hashes to other methods.

Some of the behavior here is questionable, such as allocating
different numbers of objects depending on whether a block is
passed or whether YJIT is enabled. I think there are likely ways
to eliminate allocations in certain cases.  However, this gives
us a baseline and shows us where it is possible to make
improvements.
If the method being called does not have a keyword splat parameter,
there is no point in allocating the hash, because the hash will
be unused (as empty keyword hashes are ignored).
If the method being called does not have a positional splat
parameter, there is no point in allocating the array, as
decrementing given_argc is sufficient to ensure the empty keyword
hash is not considered an argument, assuming that we are calling
a method/lambda and not a regular proc.
@jeremyevans jeremyevans force-pushed the ruby2_keywords-allocation-tests branch from d078cfd to 335a435 Compare May 20, 2024 19:33
@jeremyevans jeremyevans merged commit 86cf074 into ruby:master May 20, 2024
100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant