You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Combining reference initialization and subtraction for full collections, with the permanent-generation bookkeeping needed to preserve gc.freeze() and gc.unfreeze() behavior.
Skipping finalizer scans and late weakref cleanup when earlier collection phases establish they are unnecessary.
Clearing unreachable flags and counting unreachable objects during existing passes.
Skipping reachability traversal for surviving exact tuples that can be untracked immediately.
In production at OpenAI, we've observed roughly a one-third reduction in GC time with these combined improvements.
The changes will be proposed in focused PRs against main, with correctness and performance measurements for each.
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)