Repository navigation
Make the garbage collector thread-safe in --disable-gil builds #112529
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixestopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement3.13only security fixesonly security fixes
on Nov 29, 2023 - added 6 commits that reference this issue
on Jan 5, 2024 - added a commit that references this issue
on Jan 16, 2024 36 remaining items
- added 2 commits that reference this issue
on Apr 2, 2024 I'm going to close this as the free-threaded GC is implemented now. We can open a new issue for refactoring out the common code.
- added 4 commits that reference this issue
on Sep 2, 2024
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixestopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
Python's cyclic garbage collector relies on the global interpreter lock for thread-safety. There are a number of changes needed to make the GC thread-safe in
--disable-gilbuilds.My intention is to implement these as a series of smaller changes.
gcstate->collecting. This need to be made thread-safe.--disable-gilbuilds should stop-the-world when finding garbage, but not when calling finalizers or destructors. (depends on Implement stop-the-world functionality (for--disable-gilbuilds) #111964)--disable-gilbuilds should find GC-enabled objects by traversing the mimalloc heaps, because the_gc_next/_gc_prevlists are not thread-safe. (Note it's safe to use the lists during stop-the-world pauses; we just can't maintain them safely during normal Python execution).--disable-gilbuilds should probably use only a single generation to avoid frequent stop-the-world pauses--disable-gilbuilds to save memory. (This will require updating the trashcan mechanism.)Remaining work:
gc.candgc_free_threaded.cSee also #111964
Linked PRs
gcstate->collecting#112533