Title: gh-112529: Implement GC for free-threaded builds by colesbury · Pull Request #114262 · python/cpython · GitHub
Open Graph Title: gh-112529: Implement GC for free-threaded builds by colesbury · Pull Request #114262 · python/cpython
X Title: gh-112529: Implement GC for free-threaded builds by colesbury · Pull Request #114262 · python/cpython
Description: This implements the GC for free-threaded builds. The free-threading GC follows the same basic algorithms as the existing GC, but operates on different data types. Specifically: GC-enabled objects are found by using mimalloc APIs to traverse heaps (instead of the PyGC_Head linked list) The ob_tid field (thread id) is abused for computing gc_refs as well as for "worklists" that keep track of the "unreachable" set of objects, objects with legacy finalizers, and weakref callbacks. The marking stack uses _PyObjectStack, a linked-list of fixed sized chunks. This requires memory allocation during GC for marking. It would be possible to avoid this, but at the cost of extra scans over the whole heap, which I don't think is worthwhile. For context, GC implementations in other languages, like OpenJDK and Go use essentially the same data structure for marking. The resurrection check uses ob_ref_local for computing gc_refs because ob_tid is in use for the "unreachable" worklist There is a bunch of clean-up and improvements that I'd like to defer to later PRs to keep this size of this manageable: Define NUM_GENERATIONS to 1 in free-threaded builds. As written, every collection in the free-threaded build is a full collection, but we still behave as if we have three generations in a few places. Remove the now unused PyGC_Head pre-header in free-threaded builds Thread-safe counting of the number of allocated objects (used to schedule GCs) Refactor out common code from Python/gc.c and Python/gc_free_threading.c once Mark's incremental GC is landed Add stop-the-world calls (needs #112471) Issue: gh-112529
Open Graph Description: This implements the GC for free-threaded builds. The free-threading GC follows the same basic algorithms as the existing GC, but operates on different data types. Specifically: GC-enabled objects ...
X Description: This implements the GC for free-threaded builds. The free-threading GC follows the same basic algorithms as the existing GC, but operates on different data types. Specifically: GC-enabled objects ...
Opengraph URL: https://github.com/python/cpython/pull/114262
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:78135620-762f-6b7b-727e-12ea53c51ad6 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | ADA4:8D142:1E424D0:27E8851:696AFCCB |
| html-safe-nonce | 4ce7149f32fc0fe99ce5c8853f7d5165642b74f7d15f9cc17f5a0f5942156380 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREE0OjhEMTQyOjFFNDI0RDA6MjdFODg1MTo2OTZBRkNDQiIsInZpc2l0b3JfaWQiOiIyNTMwMDUxMjUxNzA1MTUwNjY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 72defb8e3930e418f2f107ae4ddef5311f6843b7f73d45e212e9efc13c408de6 |
| hovercard-subject-tag | pull_request:1685474895 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/114262/files |
| twitter:image | https://avatars.githubusercontent.com/u/655866?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/655866?s=400&v=4 |
| og:image:alt | This implements the GC for free-threaded builds. The free-threading GC follows the same basic algorithms as the existing GC, but operates on different data types. Specifically: GC-enabled objects ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width