Repository navigation
Avoid redundant garbage collector traversals #159437
Copy link
Copy link
Open
Labels
3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Description
This issue tracks a series of GC optimizations that we have made in OpenAI’s CPython fork and would like to bring upstream. They target the garbage collector in GIL-enabled builds and reduce repeated walks over the same objects during collection.
The work includes:
- gh-159437: Skip unnecessary GC finalizer scans and align functions
- gh-159437: Count garbage during weakref cleanup
- gh-159437: Skip unnecessary late weakref cleanup
- gh-159437: Combine GC reference passes
- gh-159437: Skip unnecessary legacy finalizer scans
- gh-159437: Remove extra resurrection bookkeeping walks
- gh-159437: Support frozen objects in combined GC reference passes
- gh-159437: Skip tuple traversal when a tuple can be untracked
In production at OpenAI, we've observed roughly a one-third reduction in GC time with these combined improvements.
Linked PRs
- gh-159437: Remove extra resurrection bookkeeping walks #159595
- gh-159437: Combine GC reference passes #159599
- gh-159437: Count garbage during weakref cleanup #159598
- gh-159437: Skip unnecessary late weakref cleanup #159590
- gh-159437: Skip unnecessary GC finalizer scans and align functions #159587
- gh-159437: Support frozen objects in combined GC reference passes #159597
- gh-159437: Skip unnecessary legacy finalizer scans #159593
Reacted by Wulian233, An Long, Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి), Sergey Miryanov, Sacul, h-qin-epyai, Maurycy Pawłowski-Wieroński, Neil Stoker, Ankit Aglawe, Marcus Lagergren and 1 more
Reacted by Pablo Galindo Salgado, Emma Smith, Maurycy Pawłowski-Wieroński, Dave Burkholder and Bruno Cabral
Reacted by Pablo Galindo Salgado, Maurycy Pawłowski-Wieroński, stonebig and Bruno Cabral
Reacted by Pablo Galindo Salgado, An Long, Emma Smith, Sacul, Maurycy Pawłowski-Wieroński, Wulian233, Dave Burkholder and Bruno Cabral
Metadata
Metadata
Assignees
Labels
3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Activity
brandt-oai commentedon Oct 14, 2026
CC @pablogsal
picnixz commentedon Oct 14, 2026
cc @markshannon
pablogsal commentedon Oct 14, 2026
Parented to #159137 (see previous work there)
pythongh-159437: Skip traversal for untrackable tuple survivors
mfalco-oai commentedon Oct 16, 2026
I'll add fresh performance numbers and then move these out of draft
pythongh-159437: Support frozen objects in fused GC reference passes
pythongh-159437: Support frozen objects in fused GC reference passes
pythongh-159437: Support frozen objects in fused GC reference passes
pythongh-159437: Skip traversal for untrackable tuple survivors
pythongh-159437: Remove redundant tuple untracking guards