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 x Free-Threading · Issue #141594 · python/cpython

JIT x Free-Threading #141594

New issue
Copy link
New issue
Copy link
Open
Open
JIT x Free-Threading#141594
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Description

@Fidget-Spinner
Fidget-Spinner
opened on Nov 15, 2025
Issue body actions

Feature or enhancement

Proposal:

This provides an alternative design to #133171. I have a branch where all tests (including FT) pass.

Part 1:
For the first and simplest part, we could add a watcher/callback to thread creation. When multiple threads are created, we simply invalidate the executor as _CHECK_VALIDITY fails.

This means single threaded code gets all the benefits of JIT in the future, while multi-threaded code will lose all the benefits. However, both can coexist at the same time in the same build. We will finally get JIT + FT in a limited form. Pending part 2.

Part 2:
If we detect multiple threads are running, we turn off the non-thread safe optimizations, and redo the trace with those optimizations off. If we detect only a single thread, we follow part 1 and run till we get invalidated. This allows single threaded code to run faster, while multi-threaded code will run a little slower. Note that all optimizations I've proposed for the JIT in the past 6 months and in the future are FT safe (in theory. whether they are implemented in practice is different).

Together, part 1 and part 2 get the best of both worlds: for single-threaded code, we get max performance, even recovering some of the perf single-threaded perf lost from FT. In part 2, we get max compatibility with multiple threads.

We need both parts to get the max perf out of the JIT on FT.

Follow-up after this:

  • Lock/unlock removal in FT code.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

#133171

Linked PRs

  • gh-141594: A free-threaded JIT (Part 1) #141595
Reacted by Chris Eibl and Sacul

Activity

  1. Fidget-Spinner
    added
    type-featureA feature request or enhancementA feature request or enhancement
    topic-free-threading
    topic-JIT
    on Nov 15, 2025
  2. StanFromIreland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Nov 15, 2025
  3. markshannon commented on Nov 17, 2025

    @markshannon
    markshannon
    on Nov 17, 2025
    Member
    More actions

    Correct me if I'm wrong, but it seems that the key idea here is to disable the JIT if more than one thread is run.

    That could be done without all the other changes. So why make all the other changes?

  4. Fidget-Spinner commented on Nov 17, 2025

    @Fidget-Spinner
    Fidget-Spinner
    on Nov 17, 2025
    MemberAuthor
    More actions

    Correct me if I'm wrong, but it seems that the key idea here is to disable the JIT if more than one thread is run.

    Yes it is. Let me try reducing the changeset.

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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtopic-free-threadingtype-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.