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-131798: Allow the JIT to remove more int/float/str guards #131800

Merged
merged 7 commits into from
Apr 1, 2025

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Mar 27, 2025

This changes the definitions of BINARY_OP_SUBSCR_LIST_INT, BINARY_OP_SUBSCR_STR_INT, BINARY_OP_SUBSCR_TUPLE_INT, and STORE_SUBSCR_LIST_INT to use our existing int/str guards for their operands (I'll add new guards for the containers themselves in a follow-up PR). This way, they can be removed when possible.

As part of this change, get rid of the _GUARD_BOTH_FLOAT, _GUARD_BOTH_INT, and _GUARD_BOTH_UNICODE micro-ops, since they just make the abstract interpreter more complicated for not much benefit.

@brandtbucher brandtbucher added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-JIT labels Mar 27, 2025
@brandtbucher brandtbucher self-assigned this Mar 27, 2025
@brandtbucher
Copy link
Member Author

As part of this change, get rid of the _GUARD_BOTH_FLOAT, _GUARD_BOTH_INT, and _GUARD_BOTH_UNICODE micro-ops, since they just make the abstract interpreter more complicated for not much benefit.

One nice unintended effect of this: x + x has only guards the type of x once now, rather than twice.

@brandtbucher
Copy link
Member Author

Looks about 0.5% faster. According to the stats, this avoids:

  • 34 million runtime float checks (~3% of the total)
  • 695 million runtime str checks (~29% of the total)
  • 3.344 billion runtime int checks (~38% of the total)

@brandtbucher brandtbucher merged commit 1a9d4a1 into python:main Apr 1, 2025
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage topic-JIT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant