GH-129715: Don't project traces that return to an unknown caller#130024
Merged
brandtbucher merged 3 commits intopython:mainfrom Feb 12, 2025
Merged
GH-129715: Don't project traces that return to an unknown caller#130024brandtbucher merged 3 commits intopython:mainfrom
brandtbucher merged 3 commits intopython:mainfrom
Conversation
Closed
Fidget-Spinner
approved these changes
Feb 12, 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
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.
Pretty straightforward: if a trace ends by returning or yielding to an unknown caller, don't bother compiling it.
This makes the JIT almost 1% faster, since we're no longer jumping in and out of these "doomed" traces. The biggest gains are on our current "worst" benchmarks (see JIT vs. non-JIT for comparison). It does result in about 7.5% more tier one instructions being executed, since all of these little dead-end traces add up.
The plan is to handle these by "specializing"
RETURN_VALUE,RETURN_GENERATOR, andYIELD_VALUEfor known Python callers, and using that information during trace projection. That will come in follow-up PRs.This also fixes a bug in one of the instrumentation helpers (it was shaken out by this change). If an instruction is
ENTER_EXECUTOR, then it can't be instrumented. However, it is possible forENTER_EXECUTORto live alongside instrumented instructions._DYNAMIC_EXIT#129715