Title: JIT x Free-Threading · Issue #141594 · python/cpython · GitHub
Open Graph Title: JIT x Free-Threading · Issue #141594 · python/cpython
X Title: JIT x Free-Threading · Issue #141594 · python/cpython
Description: 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 multi...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/141594
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JIT x Free-Threading","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nThis provides an alternative design to https://github.com/python/cpython/issues/133171. I have a branch where all tests (including FT) pass.\n\n**Part 1:**\nFor 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.\n\nThis 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.\n\n**Part 2:**\nIf 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).\n\nTogether, 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.\n\n**We need both parts to get the max perf out of the JIT on FT**.\n\nFollow-up after this:\n* Lock/unlock removal in FT code.\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\nhttps://github.com/python/cpython/issues/133171\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-141595\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/Fidget-Spinner","@type":"Person","name":"Fidget-Spinner"},"datePublished":"2025-11-15T16:25:55Z","url":"https://github.com/python/cpython/issues/141594"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:08217b97-bbed-e030-dda6-6c4c2cdefaed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B610:282DC8:23DEE0:32452D:6AECB637 |
| html-safe-nonce | 14b4c2804a16577b9ff355a9bfee6b8abf2d7dd90c059d76cebcedc83e4e2496 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjEwOjI4MkRDODoyM0RFRTA6MzI0NTJEOjZBRUNCNjM3IiwidmlzaXRvcl9pZCI6Ijc1MDY0MTcyMjU2MjQ5MTk1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 460fcaad5ec094eaeb5403a6b28b0a6cd47a62eef446368b7e276f6a2cd9be59 |
| hovercard-subject-tag | issue:3628914151 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/141594/issue_layout |
| twitter:image | https://opengraph.githubassets.com/91842796fcc7a72daad49df4ca9f568824ee0bcf138ab147ef92ef63739c9ca1/python/cpython/issues/141594 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/91842796fcc7a72daad49df4ca9f568824ee0bcf138ab147ef92ef63739c9ca1/python/cpython/issues/141594 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Fidget-Spinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 95ae5445dec4cded2bc4f9d97ede92b9116c0bf381a08a5c844b60b5bddcbc97 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db4ef601a7f034ae2a68e17d6eeaeb7ee9470192 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width