Skip to content

GH-129715: Don't project traces that return to an unknown caller #130024

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 3 commits into from
Feb 12, 2025

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Feb 12, 2025

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, and YIELD_VALUE for 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 for ENTER_EXECUTOR to live alongside instrumented instructions.

@brandtbucher brandtbucher added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-JIT labels Feb 12, 2025
@brandtbucher brandtbucher self-assigned this Feb 12, 2025
@brandtbucher brandtbucher merged commit 11bb08e into python:main Feb 12, 2025
58 checks passed
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.

2 participants