Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
nascheme wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromnascheme:gc-revert-work-to-do-change

Conversation

@nascheme
Copy link
Member

@naschemenascheme commentedNov 27, 2025
edited by bedevere-appbot
Loading

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

gpshead and chris-eibl reacted with thumbs up emoji
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
Copy link
MemberAuthor

nascheme commentedNov 27, 2025
edited
Loading

@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.

@naschemenascheme changed the titleRevert GC changes to "work_to_do" logic.GH-142002: Revert GC changes to "work_to_do" logic.Nov 27, 2025
@naschemenascheme added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelNov 27, 2025
@bedevere-bot
Copy link

🤖 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.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelNov 27, 2025
@sergey-miryanov
Copy link
Contributor

sergey-miryanov commentedNov 27, 2025
edited
Loading

@nascheme Thanks! I will take a look.
I took some measurements in September. Maybe you'll find them interesting -faster-cpython/ideas#668 (comment)

I'm comparing 3.13 and main and have following preliminary results (I have added heap_size to gcstate in 3.13):
3.13

image

main (and I suppose this will be the same for 3.14)

image

This is for benchmarks\bm_xml_etree\run_benchmark.py --worker --pipe 556 --worker-task=0 --values 3 --min-time 0.1 --loops 1 --warmups 1 --etree-module xml.etree.ElementTree run.

@sergey-miryanov
Copy link
Contributor

sergey-miryanov commentedNov 27, 2025
edited
Loading

And another couple of screenshots that I made (they made on80e59a8)

imageimageimage

I'm not sure thatwork_to_do calculates properly at all. Maybe fixing#127519 is a key for this problem.

@gpshead
Copy link
Member

If this lands, it'll need a backport because#140447 landed in 3.14.

@gpsheadgpshead added needs backport to 3.14bugs and security fixes interpreter-core(Objects, Python, Grammar, and Parser dirs) labelsNov 28, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)needs backport to 3.14bugs and security fixes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@nascheme@bedevere-bot@sergey-miryanov@gpshead

[8]ページ先頭

©2009-2025 Movatter.jp