GH-113710: Add a peephole optimization pass.#114487
Merged
markshannon merged 4 commits intopython:mainfrom Jan 24, 2024
Merged
Conversation
Closed
Member
Author
|
One other thing to note (that I found a bit surprising) is that 94% of the |
gvanrossum
approved these changes
Jan 23, 2024
Member
gvanrossum
left a comment
There was a problem hiding this comment.
LG except for a stray blank line. I guess the trick to store the code object in the operand of frame push/pop uops is the only thing here that's even remotely clever, which is good.
Python/optimizer_analysis.c
Outdated
| static void | ||
| peephole_opt(PyCodeObject *co, _PyUOpInstruction *buffer, int buffer_size) | ||
| { | ||
|
|
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
…14487) * Convert _LOAD_CONST to inline versions * Remove PEP 523 checks
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
…14487) * Convert _LOAD_CONST to inline versions * Remove PEP 523 checks
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a simple peephole optimizer.
_LOAD_CONSTto the inline versions:_LOAD_CONST_INLINEand_LOAD_CONST_INLINE_BORROW.Benchmarking and stats show a ~0.4% speedup (which could just be noise).
There is a ~0.7% reduction in tier 2 instructions executed (from removing the PEP 523 checks).
The change to loading constants will have limited impact on the tier 2 interpreter, but the effect should be more pronounced for the JIT as the operand can be inlined.