FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-131798: Allow the JIT to remove more `int`/`float`/`str` guards by brandtbucher · Pull Request #131800 · python/cpython · GitHub

Repository navigation

GH-131798: Allow the JIT to remove more int/float/str guards - #131800

Merged
brandtbucher merged 7 commits into
python:mainfrom
brandtbucher:jit-guard-float-int-str
Apr 1, 2025
Merged

brandtbucher merged 7 commits into
python:mainfrom
brandtbucher:jit-guard-float-int-str

Conversation

brandtbucher commented Mar 27, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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 added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-JIT labels Mar 27, 2025
brandtbucher self-assigned this Mar 27, 2025

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
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 merged commit 1a9d4a1 into python:main Apr 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL