Free threaded - #23437
Closed
ndellosa95 wants to merge 7 commits into
Closed
Conversation
added 7 commits
June 23, 2026 09:04
Contributor
|
In its current iteration this change increases runtime by about 4x but increases core-engagement by about +5 on my 8 core machine. I'm investigating why. |
Contributor
Contributor
Author
|
Closed in favor of #23477 |
tobni
added a commit
that referenced
this pull request
Aug 9, 2026
Switches Pants' own runtime to free-threaded CPython and makes the engine and Pants' Python code thread-safe without the GIL. This has been validated as running without error in my companies CI, and nets great speedups. Most important callouts: - Keep a persistent per-thread PyThreadState in the executor. Without this, every `Python::attach` cycle tears down the thread state, and on 3.14t that abandons the thread's mimalloc heaps. Created per tokio thread, torn down in `on_thread_stop` (blocking threads are recycled, so the state must not leak per thread creation). - Makes run-scoped internals thread-safe: rule_visitor, exception_sink, logging, build_root, run_tracker. I used #23437 as a launching point. I have on speculation set this as shipping in 2.34.x, as I believe 2.33 is too far along the dev-cycles. But I also do not see any reason to delay further. Blocks pantsbuild/scie-pants#541 Edit: This branch now serves as proof of green CI of the accumulation of changes, and will be rebased as its parts are accepted incrementally: - #23487 - #23488 - #23489 - #23490 - #23491 - #23492 - #23497 - #23514 Edit2: Now that all pre-requisites are in, this PR contains CI/CD changes and the new PANTS_FREE_THREADED option. Current proposal for consumer UX is | Consumer | `pants.toml#[GLOBAL].pants_free_threaded` | Resolves to | Bootstrap warning | |---|---|---|---| | **scie-pants - not updated** | absent / `false` | `cp314` (GIL 3.14) | - | | **scie-pants - not updated** | `true` | `cp314` (GIL 3.14) | **"update scie-pants"**. Old launcher can't honor the field | | **scie-pants - updated** | absent (default) | `cp314t` (free-threaded) | - | | **scie-pants - updated** | `false` | `cp314` (GIL 3.14) | - (escape hatch) | | **scie-pants - updated** | `true` | `cp314t` (free-threaded) | - | | **Fat scie - `…-cp314`** | `true` | GIL 3.14 | **"no effect on a fat scie; download the binary you want"** | | **Fat scie - `…-cp314t`** | `false` | free-threaded | **"no effect on a fat scie; download the binary you want"** | This PR is coupled to pantsbuild/scie-pants#541.
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.
yeet