GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JIT optimizer cleanups · Issue #143421 · python/cpython

JIT optimizer cleanups #143421

New issue
Copy link
New issue
Copy link
Closed
Closed
JIT optimizer cleanups#143421
Copy link
Assignees
corona10Fidget-Spinner
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-featureA feature request or enhancementA feature request or enhancement

Description

@Fidget-Spinner
Fidget-Spinner
opened on Jan 4, 2026
Issue body actions

Feature or enhancement

Proposal:

Currently the JIT uop buffer modifies uops traces in place.

I think we should make it add to a new buffer. Having modifications be in-place is making our code messy and full of special cases.

So

REPLACE_OP(this_instr, ...)

should become

ADD_OP(ctx, ...)

in optimizer_bytecodes.c,

Also, the default generated case of optimizer_bytecodes.c should be to ADD_OP(pc, ...)

This is also blocking optimization in #143414, as ocassionally we need to insert extra guards to check the uniqueness of an object for example.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-143421: Move JitOptContext from stack allocation to per-thread heap allocation to avoid stack overflow. #143536
  • gh-143421: Lazily allocate tracer code and opt buffers #143597
  • gh-143421: Allocate all JIT state in one go #143626
  • gh-143421: Use new buffer to save optimized uops #143682
Reacted by Tomas R.

Activity

  1. Fidget-Spinner
    added
    type-featureA feature request or enhancementA feature request or enhancement
    topic-JIT
    on Jan 4, 2026
  2. corona10
    assigned
    corona10
    and
    Fidget-Spinner
    on Jan 5, 2026
  3. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Jan 5, 2026
  4. markshannon commented on Jan 5, 2026

    @markshannon
    markshannon
    on Jan 5, 2026
    Member
    More actions

    I agree, but let's refactor the JIT structs to be heap allocated first.

    Reacted by Ken Jin
  5. Fidget-Spinner commented on Jan 6, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Jan 6, 2026
    MemberAuthor
    More actions

    I agree, but let's refactor the JIT structs to be heap allocated first.

    Assigning this to @cocolato

  6. Fidget-Spinner
    changed the title [-]Make the JIT optimizer buffer add to a new buffer, not in-place[/-] [+] JIT optimizer cleanups[/+] on Jan 6, 2026
  7. Fidget-Spinner
    added 4 commits that reference this issue on Jan 8, 2026

    gh-143421: Move `JitOptContext` from stack allocation to per-thread h…

    aeb3403

    Revert "pythongh-143421: Move `JitOptContext` from stack allocation t…

    738696f

    gh-143421: Lazily allocate tracer code and opt buffers (GH-143597)

    b852236

    gh-143421: Allocate all JIT state in one go (GH-143626)

    e0fb278
  8. cocolato commented on Jan 10, 2026

    @cocolato
    cocolato
    on Jan 10, 2026
    Member
    More actions

    How should we handle the following case? It appears that we cannot simply use ADD_OP as a substitute. Perhaps we still need a REPLACE_OP to handle the new buffer.

    cpython/Python/optimizer_bytecodes.c

    Line 1512 in e7f5ffa

    REPLACE_OP(this_instr-1, _GUARD_GLOBALS_VERSION, 0, version);
    and

    cpython/Python/optimizer_bytecodes.c

    Line 1024 in e7f5ffa

    REPLACE_OP(this_instr+1, _NOP, 0, 0);

  9. Fidget-Spinner commented on Jan 10, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Jan 10, 2026
    MemberAuthor
    More actions

    @cocolato make REPLACE_OP operate on the new buffer instead of the old one. Ideally you should have two buffers. An old buffer containing the current uops, and a new buffer, containing the uops being written.

    If the optimizer stops early, you can just insert an _EXIT_TRACE at that location in the new buffer.

    Reacted by Hai Zhu
  10. reidenong
    added 3 commits that reference this issue on Jan 12, 2026

    pythongh-143421: Move `JitOptContext` from stack allocation to per-th…

    86e3e81

    pythongh-143421: Lazily allocate tracer code and opt buffers (pythonG…

    ac9af52

    pythongh-143421: Allocate all JIT state in one go (pythonGH-143626)

    d0fb0b4
  11. Fidget-Spinner
    added a commit that references this issue on Jan 17, 2026

    gh-143421: Use new buffer to save optimized uops (GH-143682)

    b4b7324
  12. Fidget-Spinner
    closed this as completedon Jan 21, 2026
  13. thunder-coding
    added 4 commits that reference this issue on Feb 15, 2026

    pythongh-143421: Move `JitOptContext` from stack allocation to per-th…

    d7bb693

    pythongh-143421: Lazily allocate tracer code and opt buffers (pythonG…

    bc68e75

    pythongh-143421: Allocate all JIT state in one go (pythonGH-143626)

    f5742c8

    pythongh-143421: Use new buffer to save optimized uops (pythonGH-143682)

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

Metadata

Metadata

Assignees

  • @Fidget-Spinner
    Fidget-Spinner
  • @corona10
    corona10

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.