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

gh-120619: Strength reduce function guards, support 2-operand instruction forms #124846

Merged
merged 12 commits into from
Nov 9, 2024

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Oct 1, 2024

  1. This eliminates _CHECK_FUNCTION_EXACT_ARGS if we can statically determine the number of arguments at optimization time.
  2. This also strength reduces _CHECK_FUNCTION_VERSION to not need to read the stack operands. To do this, we need a 2-operand form of uops. This PR thus adds support for that.

Altogether, these prepare it for partial evaluation in the future, as after removing these guards, this means the inputs do not need to be materialized.

@Fidget-Spinner Fidget-Spinner changed the title gh-120619: Strength reduce function guards gh-120619: Strength reduce function guards, support 2-operand instruction forms Nov 4, 2024
@Fidget-Spinner
Copy link
Member Author

@markshannon can you please bengmchmark this?

@markshannon
Copy link
Member

No significant performance impact, 0.3% faster on average.
https://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20241104-3.14.0a1+-6d6263c-JIT

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Looks generally sound.

One assert and comment seem incorrect.
Maybe rename operand to operand0 if we are adding operand1

Include/internal/pycore_optimizer.h Outdated Show resolved Hide resolved
Python/optimizer_bytecodes.c Outdated Show resolved Hide resolved
Python/optimizer_bytecodes.c Outdated Show resolved Hide resolved
@bedevere-app
Copy link

bedevere-app bot commented Nov 6, 2024

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

There's a test that can be removed, otherwise LGTM.

Python/optimizer_bytecodes.c Outdated Show resolved Hide resolved
Tools/jit/template.c Outdated Show resolved Hide resolved
@markshannon
Copy link
Member

Looks good to me.

@brandtbucher can you approve if you are happy with the JIT changes?

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

JIT changes look good, just a couple out-of-date comments:

Tools/jit/_stencils.py Outdated Show resolved Hide resolved
Tools/jit/_stencils.py Outdated Show resolved Hide resolved
Tools/jit/_stencils.py Outdated Show resolved Hide resolved
@Fidget-Spinner Fidget-Spinner merged commit 6293d00 into python:main Nov 9, 2024
65 checks passed
@Fidget-Spinner Fidget-Spinner deleted the eliminate_func_guards branch November 9, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants