Skip to content

_TIER2_RESUME_CHECK is costly in the JIT #134728

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

Open
Fidget-Spinner opened this issue May 26, 2025 · 5 comments
Open

_TIER2_RESUME_CHECK is costly in the JIT #134728

Fidget-Spinner opened this issue May 26, 2025 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage topic-JIT type-feature A feature request or enhancement

Comments

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented May 26, 2025

Feature or enhancement

Proposal:

_TIER2_RESUME_CHECK deopts around every few thousand loop iterations. This is really costly to the JIT, as we want to stay in the JITted code as far as possible.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@markshannon
Copy link
Member

markshannon commented May 26, 2025

Why is the eval breaker set so often, and why is executing a few instructions in the interpreter so expensive?

@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 26, 2025
@Fidget-Spinner
Copy link
Member Author

Why is the eval breaker set so often, and why is executing a few instructions in the interpreter so expensive?

I have no clue to the former. To the latter, it's not that executing a few instructions in the interpreter is expensive, more like every few thousand iterations, we're forced to exit to the interpreter for no reason other than some eval breaker being set. This deopt is extremely costly.

@brandtbucher
Copy link
Member

I’d also like to run some benchmarks on this, and separately, learn what’s being set. My guess is that it’s either GC or our cold trace invalidation. If it’s the latter, it should be fixed.

In general, I’d like to kick back into the interpreter for failed eval breaker checks, since handling them is an escaping call, and also just a bulky chunk of machine code that basically never runs.

@brandtbucher
Copy link
Member

FYI, here’s the threshold for cold trace cleanup. Maybe we shouldn’t leave JIT code for this? Or possibly the mechanism could be reworked. I’d rather not just tweak the threshold to make microbenchmarks happy:

#define JIT_CLEANUP_THRESHOLD 100000

@brandtbucher
Copy link
Member

But yeah, I think we should move in the opposite direction than you’re going here (change things like _CHECK_PERIODIC to deopt instead of handling breakers themselves).

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 type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants