GeezerVison is showing github.com — GH-141890: Fix GC double-counting of marked objects by brandtbucher · Pull Request #141891 · python/cpython
Conversation
brandtbucher
commented
Nov 24, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This move happens twice: once here, and once in gc_collect_increment (the caller).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
JFYI, #127519
With marking added to the cyclic GC (#127110) we spend a lot of the time in the GC forming transitive closures, both for marking and for the increments of the incremental GC.
Unfortunately the current algorithm has a couple of mistakes in it. One harmful, one beneficial.
The beneficial one is counting the initial mark twice. This helps because it reduces the cost of GC on heaps with little or no garbage
The harmful one is allowing the amount of work done to grow in proportion to the heap size.
Unfortunately, #127519 was reverted.
I had planned to try to fix it, but it's still on my to-do list.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ah, interesting. Let's benchmark this change. If the current version is better, we can just multiply by two to be explicit instead of the current code (which looks like a mistake, because originally it was). :)
|
efimov-mikhail reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The generational GC has landed, so this can be closed. Would you like me to close this?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|