Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.5k
GH-142002: Revert GC changes to "work_to_do" logic.#142001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
This reverts parts of thepythonGH-140262 change. The changes that affect thetuple untracking are left unchanged. Revert the changes to thecalculation of the increment size, based on the "work_to_do" variable.This causes cyclic garbage to be collected more quickly. Revert alsothe change to test_gc.py, which was done because the expected GCcollection was taking longer to happen.With the tuple untrack change, the performance regression as reported bybugpythonGH-139951 is still resolved (work_to_do changes are not required).
nascheme commentedNov 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@sergey-miryanov given your recent good work on GC related things, you might want to take a look at this. This PR is an attempt at a quick fix, making the code work like the 3.14.0 release in this respect. However, for 3.15 I'm thinking we need to have a more careful look at how the GC increment size is computed. I'm going to create another PR that adds a "mark-alive" pass to the full GC run. That gives about a 2X performance improvement for full (manual) GC runs. |
bedevere-bot commentedNov 27, 2025
🤖 New build scheduled with the buildbot fleet by@nascheme for commitfef3eed 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F142001%2Fmerge If you want to schedule another build, you need to add the🔨 test-with-buildbots label again. |
sergey-miryanov commentedNov 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nascheme Thanks! I will take a look.
![]()
![]()
|
sergey-miryanov commentedNov 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
gpshead commentedNov 28, 2025
If this lands, it'll need a backport because#140447 landed in 3.14. |





Uh oh!
There was an error while loading.Please reload this page.
This reverts parts of theGH-140262 change. The changes that affect the tuple untracking are left unchanged. Revert the changes to the calculation of the increment size, based on the "work_to_do" variable. This causes cyclic garbage to be collected more quickly. Revert also the change to test_gc.py, which was done because the expected GC collection was taking longer to happen.
With the tuple untrack change, the performance regression as reported by bugGH-139951 is still resolved (work_to_do changes are not required).
One way to test the effect of this change is to run the following quick-and-dirty script. It creates many reference cycles and then counts how many are not yet collected by the GC. At the end of the run, the maximum number of outstanding garbage objects are printed. With Python 3.13 (non-incremental GC), I get a max of less than 100 objects. With 3.14.0, I get approximately 2000 as the max. With the "main" branch (and 3.14 branch), I get 10,000 as the max.
gc_report_cycles.py