-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
Title: JIT/Tier 2 tracing: plans for function-entry hotness triggers (hot callbacks from C loops)?
Question
When experimenting with the experimental JIT (PEP 744), I got the impression that trace construction / compilation is primarily triggered by loop/backedge warmup (e.g. JUMP_BACKWARD backoff counters) plus side-exit temperature mechanics, rather than by “hot function entry” call counts.
If that’s correct:
- Is this an intentional design choice for now?
- Are there plans (or prior discussions) to support function-entry hotness triggers too?
Why I’m asking (workloads impacted)
Some real workloads execute a small Python callback many times from C-level loops, so there may be no Python-level backedge to ever warm up. Examples include:
sorted(..., key=callback)/list.sort(key=callback)- regex callbacks (
re.sub(..., repl=callable)) - some
itertools/ C extension APIs that repeatedly invoke a Python callable
In these cases, the callback function can be extremely hot, but a loop/backedge-only trigger would not start tracing/compilation for it.
(For reference, other runtimes/JITs (e.g. Cinder) can also trigger compilation from hot functions, not only hot loops.)
Minimal example (no Python loop)
def key(x):
return (x * 3) ^ 0x1234
data = list(range(500_000))
sorted(data, key=key) # key() is called many times from C