{{ message }}
GH-115802: Don't JIT zero-length jumps - #116177
Merged
Merged
Conversation
13 tasks
Member
Member
Author
|
No ARM benchmarks (we only have a Mac runner, and that’s not supported yet). Windows x86_64 is linked above. |
markshannon
approved these changes
Mar 1, 2024
markshannon
left a comment
Member
There was a problem hiding this comment.
Looks good.
The 32 bit Windows results are a bit strange, but I don't think it's worth worrying about for now.
I'm still seeing the final jump in the generated assembly.
How much effort would it be to clean that up?
Member
Author
woodruffw
pushed a commit
to woodruffw-forks/cpython
that referenced
this pull request
Mar 4, 2024
adorilson
pushed a commit
to adorilson/cpython
that referenced
this pull request
Mar 25, 2024
diegorusso
pushed a commit
to diegorusso/cpython
that referenced
this pull request
Apr 17, 2024
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.

Many of our JIT templates end with a jump to the next opcode. This is generally needed to ensure correct control flow... but when the jump is the very last instruction, it's entirely unnecessary. Instead, we can just continue execution into the next instruction.
This removes these jumps for the following platforms (performance results):
x86_64-pc-windows-msvc(2% faster)i686-pc-windows-msvc(3% slower)x86_64-apple-darwin(no benchmarks)aarch64-unknown-linux-gnu(no benchmarks)x86_64-unknown-linux-gnu(2% faster)(
aarch64-apple-darwinneeds a bit more work, since the final jump is still made up of 3 instructions. That can come next.)I'm assuming that the 32-bit Windows result is a fluke. If it's indeed the case that leaving the zero-length jumps in is faster, then we could easily remove this later by commenting out that case in
remove_jump. If so, maybe it's an alignment thing and we should just pad withnops instead.Also, this will probably be even more effective once we have hot/cold splitting of some kind. Most of the templates end with error handling or deoptimization code, and still have to jump over it to get to the next instruction.