Title: [subinterpreter] Make type version tag counter threadsafe for per interpreter GIL · Issue #95795 · python/cpython · GitHub
Open Graph Title: [subinterpreter] Make type version tag counter threadsafe for per interpreter GIL · Issue #95795 · python/cpython
X Title: [subinterpreter] Make type version tag counter threadsafe for per interpreter GIL · Issue #95795 · python/cpython
Description: The next_version_tag in typeobject.c is currently not thread safe and relies on GIL to protect against concurrent increments across threads. cpython/Objects/typeobject.c Lines 46 to 50 in 63140b4 // bpo-42745: next_version_tag remains sh...
Open Graph Description: The next_version_tag in typeobject.c is currently not thread safe and relies on GIL to protect against concurrent increments across threads. cpython/Objects/typeobject.c Lines 46 to 50 in 63140b4 /...
X Description: The next_version_tag in typeobject.c is currently not thread safe and relies on GIL to protect against concurrent increments across threads. cpython/Objects/typeobject.c Lines 46 to 50 in 63140b4 /...
Opengraph URL: https://github.com/python/cpython/issues/95795
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[subinterpreter] Make type version tag counter threadsafe for per interpreter GIL","articleBody":"The `next_version_tag` in `typeobject.c` is currently not thread safe and relies on GIL to protect against concurrent increments across threads. \r\n\r\nhttps://github.com/python/cpython/blob/63140b445e4a303df430b3d60c1cd4ef34f27c03/Objects/typeobject.c#L46-L50\r\n\r\n\r\nFor per-interpreter GIL, it must be made thread-safe otherwise the type cache will be affected by race conditions. Static types are not affected because they are immutable so this is a issue for pure Python classes aka heap types. This issue is for discussion of possible implementations.\r\n\r\n---\r\n\r\nPossible Solutions:\r\n- Make the `next_version_tag` counter per interpreter, while this may seems to fix the issue but since objects are shared across the interpreters and the type version tag is also used to represent a current state of a type in the specializing interpreter, two interpreters can have same the same tag for different types this won't work as expected.\r\n- Make the `next_version_tag` an atomic counter and increment it atomically using the `pyatomic APIs`. This is my preferred solution since `next_version_tag` is only modified when a type is modified so is a rare operation and not a performance issue. Since this is just a counter `relaxed ordering` can be used here.\r\n\r\n\r\ncc @ericsnowcurrently \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-102343\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/kumaraditya303","@type":"Person","name":"kumaraditya303"},"datePublished":"2022-08-08T14:14:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/95795/cpython/issues/95795"}
| 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:b6f42f16-0304-7d26-499e-4fdcd80ec94a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6EC:30B952:5FB7B3:8248D3:6969DC3B |
| html-safe-nonce | 0fb92ae22eb6f85825a39305706be38c80990c9cc5f3ed0994545535f78c9ab8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkVDOjMwQjk1Mjo1RkI3QjM6ODI0OEQzOjY5NjlEQzNCIiwidmlzaXRvcl9pZCI6IjU5OTEyODUxMDk3Mjc4MTI2NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 317fa53c8d8b11e9aba4bd56e53650d3db672ed08ec591075efd58bc085646b1 |
| hovercard-subject-tag | issue:1331939521 |
| 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/95795/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a73619c684497a71e8a9f7e516331fe7c9458d462d211c2b818a65748be0521/python/cpython/issues/95795 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a73619c684497a71e8a9f7e516331fe7c9458d462d211c2b818a65748be0521/python/cpython/issues/95795 |
| og:image:alt | The next_version_tag in typeobject.c is currently not thread safe and relies on GIL to protect against concurrent increments across threads. cpython/Objects/typeobject.c Lines 46 to 50 in 63140b4 /... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kumaraditya303 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width