-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-109039: Branch prediction for Tier 2 interpreter #109038
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
44db701
inst() and macro() may need cache size metadata
gvanrossum ff29ab3
Add cache entry to *POP_JUMP_IF_* instructions
gvanrossum ebc91a2
Fix test_dis (also fixes test_peepholer)
gvanrossum 072bb38
Fix test_monitoring
gvanrossum 896ae53
Include pycore_bitutils.h in instrumentation.c
gvanrossum 0eb5b90
Follow likely jumps in trace
gvanrossum 25bfb3d
Merge remote-tracking branch 'upstream/main' into count-branches
gvanrossum a9c0805
Require 16 iterations before optimizing
gvanrossum 7dfb94c
Fix existing uops tests
gvanrossum 73eb60f
Add test for branch prediction
gvanrossum fbd322a
Initialize POP_JUMP_IF* counters to 0x5555
gvanrossum ed045d7
Update counter in INSTRUMENTED_POP_JUMP_IF_FALSE
gvanrossum 1850988
Simplify writing of _PyOpcode_Caches
gvanrossum 4f1684c
Fix test_huntrleaks under -Xuops
gvanrossum cb2cf12
Fix test_dis under -Xuops
gvanrossum d74670c
Merge branch 'main' into count-branches
gvanrossum 41463a5
Update magic number
gvanrossum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need also a SKIP_OVER the cache?
I'm guessing that could cause the
assert(frame->prev_instr == instr);
in_Py_call_instrumentation_jump
to fail for the instrumented jumps.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That skip over the cache is already generated -- see the corresponding code in generated_cases.c.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the "next_instr += 1;"? In all other cases there is an explicit
SKIP_OVER(INLINE_CACHE_ENTRIES_...)
in bytecodes.c.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those SKIP_OVER() calls are always followed by a DISPATCH() call (or maybe a goto).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Can we make the code generator emit
SKIP_OVER(X)
instead ofnext_instr += x;
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, though IIRC Mark at some point objected to emitting macros. So I'd rather keep the status quo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markshannon What is the reason not to emit macros?
A reason to emit them is so that they are implemented in one place, so if their implementation changes you only change there. Do we want to change the code generator (and to remember that we need to) every time the implementation of a macro like SKIP_OVER changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I don't expect SKIP_OVER() to ever change. In hand-written code the macro expresses the intent better. But in generated code it just obscures what happens. I had to go to some lengths to change PEEK() and POKE() calls in the generated code to using stack_pointer[x] instead; I don't want to go back. If you still disagree, try engaging @markshannon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like trying to understand than disagreeing.
Yes I directed my previous comment to him.