Title: Make the specializing interpreter thread-safe in `--disable-gil` builds · Issue #115999 · python/cpython · GitHub
Open Graph Title: Make the specializing interpreter thread-safe in `--disable-gil` builds · Issue #115999 · python/cpython
X Title: Make the specializing interpreter thread-safe in `--disable-gil` builds · Issue #115999 · python/cpython
Description: Feature or enhancement Proposal: In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded builds, which will be correct but will in...
Open Graph Description: Feature or enhancement Proposal: In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded b...
X Description: Feature or enhancement Proposal: In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded b...
Opengraph URL: https://github.com/python/cpython/issues/115999
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make the specializing interpreter thread-safe in `--disable-gil` builds","articleBody":"# Feature or enhancement\r\n\r\n### Proposal:\r\n\r\nIn free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded builds, which will be correct but will incur a performance penalty. Then we can work out how to properly support specialization in a free-threaded build.\r\n\r\nThese two commits from Sam's nogil-3.12 branch can serve as inspiration:\r\n1. [specialize: make specialization thread-safe\r\n](https://github.com/colesbury/nogil-3.12/commit/7e7568672d)\r\n2. [specialize: optimize for single-threaded programs](https://github.com/colesbury/nogil-3.12/commit/90d34f0d18)\r\n\r\nThere are two primary concerns to balance while implementing this functionality on `main`:\r\n1. **Runtime overhead**: There should be no performance impact on normal builds, and minimal performance impact on single-threaded code running in free-threaded builds.\r\n2. **Reducing code duplication/divergence**: We should come up with a design that is minimally disruptive to ongoing work on the specializing interpreter. It should be easy for other devs to keep the free-threaded build working without having to know too much about it.\r\n\r\n### Has this already been discussed elsewhere?\r\n\r\nI have already discussed this feature proposal on Discourse\r\n\r\n### Links to previous discussion of this feature:\r\n\r\n- https://peps.python.org/pep-0703/\r\n- https://github.com/python/cpython/issues/108219\r\n\r\n### Specialization Families\r\n```[tasklist]\n- [x] BINARY_OP\n- [x] BINARY_SUBSCR - @corona10\n- [x] CALL - @mpage\n- [x] CALL_KW - @mpage\n- [x] COMPARE_OP - @Yhg1s\n- [x] CONTAINS_OP - @corona10\n- [x] FOR_ITER - @Yhg1s\n- [x] LOAD_ATTR - @mpage\n- [x] LOAD_CONST\n- [x] LOAD_GLOBAL - @mpage\n- [x] LOAD_SUPER_ATTR - @nascheme\n- [x] RESUME\n- [x] SEND - @nascheme\n- [x] STORE_ATTR - -@nascheme\n- [x] STORE_SUBSCR - @colesbury\n- [x] TO_BOOL - @corona10\n- [x] UNPACK_SEQUENCE - @Eclips4\n```\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-116013\r\n* gh-123926\r\n* gh-124953\r\n* gh-124997\r\n* gh-126410\r\n* gh-126414\r\n* gh-126440\r\n* gh-126450\r\n* gh-126498\r\n* gh-126515\r\n* gh-126600\r\n* gh-126607\r\n* gh-126616\r\n* gh-127030\r\n* gh-127123\r\n* gh-127128\r\n* gh-127167\r\n* gh-127169\r\n* gh-127227\r\n* gh-127426\r\n* gh-127514\r\n* gh-127711\r\n* gh-127713\r\n* gh-127737\r\n* gh-127838\r\n* gh-128164\r\n* gh-128166\r\n* gh-128637\r\n* gh-128798\n* gh-129365\n* gh-131285\n* gh-133824\n* gh-134286\n* gh-134348\n* gh-136249\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/swtaarrs","@type":"Person","name":"swtaarrs"},"datePublished":"2024-02-27T19:08:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/115999/cpython/issues/115999"}
| 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:5b723ba2-5e64-3459-d0f0-64421e84fca5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5B0:76A99:FCE072:15A0B1D:6A55C2DF |
| html-safe-nonce | 1d0fdc4b00e8ec6ed1d481f066774e470f408feda4bde7398fe4e541764d4ada |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUIwOjc2QTk5OkZDRTA3MjoxNUEwQjFEOjZBNTVDMkRGIiwidmlzaXRvcl9pZCI6IjQ2MzYxNTYyNDQxOTMwMzQ5NzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e24bd38db620c1b338fac0c6850c13d946964c016b772296a5442746ec55e904 |
| hovercard-subject-tag | issue:2157407839 |
| 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/115999/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d0fa09ecba74b3674118a4c409391a0d8bb5d46b28cf0227fdb55eada6771d02/python/cpython/issues/115999 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d0fa09ecba74b3674118a4c409391a0d8bb5d46b28cf0227fdb55eada6771d02/python/cpython/issues/115999 |
| og:image:alt | Feature or enhancement Proposal: In free-threaded builds, the specializing adaptive interpreter needs to be made thread-safe. We should start with a small PR to simply disable it in free-threaded b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | swtaarrs |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 8f8e1726192df8dce16872ceb503336c12e9ae78 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width