Skip to content

JIT/Tier 2 tracing: plans for function-entry hotness triggers (hot callbacks from C loops)? #143778

Description

@113xiaoji

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

Activity

  1. changed the title [-]Title: JIT: consider triggering trace recording from hot function entries (not only loop/backedge hot spots)[/-] [+]JIT: consider triggering trace recording from hot function entries (not only loop/backedge hot spots)[/+] on Jan 13, 2026
  2. changed the title [-]JIT: consider triggering trace recording from hot function entries (not only loop/backedge hot spots)[/-] [+]JIT/Tier 2 tracing: plans for function-entry hotness triggers (hot callbacks from C loops)?[/+] on Jan 13, 2026
  3. Fidget-Spinner commented on Jan 13, 2026

    @Fidget-Spinner
    Member

    Please see #142982. We do plan to eventually trace from function entry.

  4. Fidget-Spinner commented on Mar 16, 2026

    @Fidget-Spinner
    Member

    @113xiaoji I see that you're interested in AArch64 performance?

    Right now, the 3.15 JIT benchmarks around 9-10% faster on pyperformance than tail-calling interpreter on macOS AArch64 https://doesjitgobrrr.com/.

    3.13-3.14 JIT will have mostly no speedup (in fact, negative probably) for AArch64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions