gh-141594: A free-threaded JIT (Part 1)#141595
Open
Fidget-Spinner wants to merge 62 commits intopython:mainfrom
Open
gh-141594: A free-threaded JIT (Part 1)#141595Fidget-Spinner wants to merge 62 commits intopython:mainfrom
Fidget-Spinner wants to merge 62 commits intopython:mainfrom
Conversation
Member
Author
|
@sergey-miryanov in the future could you please bundle up your reviews and send them in one review instead of multiple reviews? |
19 tasks
Member
Author
|
Latest results for macOS FT+JIT are incredibly good: 8-10% faster on pyperformance versus just FT-only. |
tomasr8
reviewed
Jan 7, 2026
Member
tomasr8
left a comment
There was a problem hiding this comment.
Not an expert in this area, but everything looks reasonable. I just have a couple of comments/questions as usual :)
Comment on lines
+1578
to
+1579
| // There's more than one thread. In FT mode, | ||
| // disable the JIT completely for now. |
Member
There was a problem hiding this comment.
Do you think it's feasible to add a test that ensures the JIT is properly disabled and then re-enabled?
Member
Author
There was a problem hiding this comment.
I added a test, thanks!
|
This PR is stale because it has been open for 30 days with no activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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: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.