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 — gh-141594: A free-threaded JIT (Part 1) by Fidget-Spinner · Pull Request #141595 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Nov 15, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR gives the JIT free-threading support. It is only on for single-threaded code, and turns off automatically on multi-threaded code. All JIT features are turned on, including the optimizer. All tests pass on my system, including TSAN as of 527aac1 usng the FT suppression file, except for the usual spurious race conditions already in existing CPython.

Benchmark results are good. Overall speedup of 5% faster on FT+JIT vs just FT for x86-64 https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20260110-3.15.0a3%2B-5d987e8-JIT%2CNOGIL/bm-20260110-vultr-x86_64-Fidget%252dSpinner-jit_ft-3.15.0a3%2B-5d987e8-vs-base.md

9-10% speedup for macOS AArch64 for FT+JIT vs FT https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20260110-3.15.0a3%2B-5d987e8-JIT%2CNOGIL/bm-20260110-macm4pro-arm64-Fidget%252dSpinner-jit_ft-3.15.0a3%2B-5d987e8-vs-base.md

Design:
Creation of >1 threads cause global invalidation of all executors and disables JIT. Once we drop to 1 thread, JIT is re-enabled.

Two versions of stencils are required --- one for max single threaded perf, one for multi-threaded safety. This just implements the first part (max single threaded perf) stencils.

All with FT+PGO+LTO=thin+TC+JIT + pyperf system tune:

Mean +- std dev: [nogil-float-lock] 69.9 ms +- 1.5 ms -> [nogil-float-nolock] 54.9 ms +- 0.8 ms: 1.27x faster
Mean +- std dev: [nogil-nbody-lock] 139 ms +- 1 ms -> [nogil-nbody-nolock] 115 ms +- 3 ms: 1.21x faster
Mean +- std dev: [nogil-richards-lock] 37.3 ms +- 0.4 ms -> [nogil-richards-nolock] 35.8 ms +- 0.3 ms: 1.04x faster 
Mean +- std dev: [nogil-deltablue-lock] 3.50 ms +- 0.15 ms -> [nogil-deltablue-nolock] 3.36 ms +- 0.14 ms: 1.04x faster

This is on a platform where locking/atomics are somewhat slow (i7-12700h). I removed the lock removal code for this PR to reduce the diff.

  • Issue: JIT x Free-Threading #141594

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

efimov-mikhail, sergey-miryanov, sesav, savannahostrowski, AIdjis, chris-eibl, AlexWaygood, Sacul0457, corona10, yihong0618, and 5 more reacted with rocket emoji
All reactions
  • 🚀 15 reactions
Fidget-Spinner added 15 commits November 13, 2025 21:17
@Fidget-Spinner
Move all JIT fields to thread state
6a3bd75
@Fidget-Spinner
fix a bug with traversing states
ba9a65a
@Fidget-Spinner
fix JIT invalidation mechanism for FT
725894d
@Fidget-Spinner
fix re-entrant finalizers
1e5713d
@Fidget-Spinner
Re-enable the JIT
f0d4c57
@Fidget-Spinner
cleanup a little
67de7d6
@Fidget-Spinner
fix weird GC bugs
7f0bc57
@Fidget-Spinner
re-enable jit on some stuff
f05e61c
@Fidget-Spinner
fix test, more locks!
f78e8c8
@Fidget-Spinner
fix JIT builds
e1f1b30
@Fidget-Spinner
only clear at end
53c5e1d
@Fidget-Spinner
remove locks in JIT code
cc38ee4
@Fidget-Spinner
fix a few bugs
f8fefb3
@Fidget-Spinner
Improve tracer thread safety
d76a24b
@Fidget-Spinner
set immortal before GC
fa99108
@Fidget-Spinner
Fidget-Spinner requested review from ZeroIntensity, ericsnowcurrently and markshannon as code owners November 15, 2025 16:28
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 15, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 15, 2025
JIT x Free-Threading #141594
Open
blurb-it Bot and others added 2 commits November 15, 2025 16:30
@blurb-it
📜🤖 Added by blurb_it.
fcfed96
@Fidget-Spinner
fix default builkd
ba67ab7
sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Lib/test/test_capi/test_opt.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Objects/listobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/bytecodes.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/bytecodes.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/pylifecycle.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/pylifecycle.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov reviewed Nov 15, 2025
View reviewed changes
Comment thread Python/sysmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Nov 15, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@sergey-miryanov in the future could you please bundle up your reviews and send them in one review instead of multiple reviews?

efimov-mikhail and sergey-miryanov reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Fidget-Spinner added 2 commits December 16, 2025 22:43
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into jit_ft
8190a5c
@Fidget-Spinner
disable DCE pass for now
973e961
@Fidget-Spinner
Fidget-Spinner requested review from brandtbucher, diegorusso and savannahostrowski as code owners December 17, 2025 00:44
Fidget-Spinner added 7 commits December 17, 2025 22:52
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into jit_ft
2f39aa8
@Fidget-Spinner
comment out object locks
e08c434
@Fidget-Spinner
enable GIL on JIT
00ae7b5
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into jit_ft
4d9ffa1
@Fidget-Spinner
fix upstream merges
a1ca3a7
@Fidget-Spinner
minor fixups
cdbbbe3
@Fidget-Spinner
Fix a bug
0678505
@Fidget-Spinner

Fidget-Spinner commented Dec 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Latest results for macOS FT+JIT are incredibly good: 8-10% faster on pyperformance versus just FT-only.

https://github.com/facebookexperimental/free-threading-benchmarking/tree/main/results/bm-20251228-3.15.0a3%2B-0678505-JIT%2CNOGIL

dolfinus reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into jit_ft
dc1e25c
tomasr8
tomasr8 reviewed Jan 7, 2026
View reviewed changes

@tomasr8 tomasr8 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an expert in this area, but everything looks reasonable. I just have a couple of comments/questions as usual :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Objects/typeobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/funcobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/sysmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/pystate.c
Comment on lines +1578 to +1579
// There's more than one thread. In FT mode,
// disable the JIT completely for now.

@tomasr8 tomasr8 Jan 7, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's feasible to add a test that ensures the JIT is properly disabled and then re-enabled?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Fidget-Spinner Fidget-Spinner Jan 9, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Fidget-Spinner added 8 commits January 7, 2026 22:52
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into jit_ft
c2416a6
@Fidget-Spinner
Address review comments
65b6dd0
@Fidget-Spinner
reduce diff
7d97437
@Fidget-Spinner
fix build
1a4f2d0
@Fidget-Spinner
Add a test
2494965
@Fidget-Spinner
reduce diff
aff296a
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into jit_ft
8df9aed
@Fidget-Spinner
check env var when re-enabling
fb56baa
@Fidget-Spinner Fidget-Spinner changed the title gh-141594: A free-threaded JIT gh-141594: A free-threaded JIT (Part 1) Jan 10, 2026
@Fidget-Spinner
fix warnings
5d987e8
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 2, 2026
@merwok merwok removed the stale Stale PR or inactive for long period of time. label Jun 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sergey-miryanov sergey-miryanov sergey-miryanov left review comments
@corona10 corona10 corona10 left review comments
@efimov-mikhail efimov-mikhail efimov-mikhail left review comments
@tomasr8 tomasr8 tomasr8 left review comments
@markshannon markshannon markshannon left review comments
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity is a code owner
@brandtbucher brandtbucher Awaiting requested review from brandtbucher brandtbucher is a code owner
@savannahostrowski savannahostrowski Awaiting requested review from savannahostrowski
@diegorusso diegorusso Awaiting requested review from diegorusso diegorusso is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@Fidget-Spinner @sergey-miryanov @markshannon @corona10 @efimov-mikhail @tomasr8 @merwok
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.