GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-159137: Untrack tuples and count survivors in move_unreachable() by pablogsal · Pull Request #159154 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Oct 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

After finding the surviving objects, the collector walks them two more times: once in untrack_tuples() and once in gc_list_size() just to count them. move_unreachable() already visits each survivor, so this does both there and drops the two walks.

Benchmarks

GC time from gc.get_stats(). Medians of four runs per executable (nine for the AST heap), in baseline/candidate/candidate/baseline order.

Workload GC before GC after Less GC time
Sphinx building the CPython docs 27.956 s 20.387 s 27.1%
Pylint on five stdlib packages 2.740 s 1.607 s 41.4%
Parso parsing the standard library 1.397 s 0.860 s 38.4%
sqlglot parsing and transpiling 4,000 queries 4.248 s 2.900 s 31.7%
Beautiful Soup parsing 90 HTML pages 2.122 s 1.485 s 30.0%
Black checking three stdlib packages 1.643 s 1.460 s 11.1%
Full collection of 720,000 live AST objects 292.4 ms 153.0 ms 47.7%
Geometric mean 33.3%

Collector cycles on the Pylint run. Width is the share before the change, blue frames take fewer cycles after it:

pylint

  • Issue: Speed up garbage collector #159137

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

maurycy reacted with heart emoji nascheme reacted with rocket emoji
All reactions
  • ❤️ 1 reaction
  • 🚀 1 reaction
@pablogsal
pythongh-159137: Untrack tuples and count survivors in move_unreachab…
4a47f38
…le()
@bedevere-app bedevere-app Bot mentioned this pull request Oct 10, 2026
Speed up garbage collector #159137
Open
@pablogsal pablogsal mentioned this pull request Oct 10, 2026
gh-159137: gc: Count GC survivors in untrack_tuples() instead of walking the young generation again #159149
Closed
sergey-miryanov
sergey-miryanov reviewed Oct 10, 2026
View reviewed changes
Comment thread Python/gc.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/gc.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
pablogsal marked this pull request as ready for review October 10, 2026 22:45
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 10, 2026
@pablogsal
pablogsal requested a review from nascheme October 10, 2026 22:45
@pablogsal
Check for an untracked tuple only in the tuple branch and add a NEWS …
6c50d7b
…entry
@pablogsal pablogsal mentioned this pull request Oct 11, 2026
gh-159137: Restore known-root marking for the GIL garbage collector #159162
Closed
sergey-miryanov
sergey-miryanov approved these changes Oct 11, 2026
View reviewed changes
Comment thread Python/gc.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Oct 11, 2026
@pablogsal @sergey-miryanov
Update Python/gc.c
a75955d
Co-authored-by: Sergey Miryanov <[email protected]>
@pablogsal
pablogsal enabled auto-merge (squash) October 11, 2026 15:44
@pablogsal
pablogsal merged commit e878e1e into python:main Oct 11, 2026
55 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
pablogsal deleted the gh-159137-gc-fold-survivor-walks branch October 11, 2026 16:01
@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 11, 2026
orsenthil pushed a commit to orsenthil/cpython that referenced this pull request Oct 11, 2026
@pablogsal @orsenthil
pythongh-159137: Untrack tuples and count survivors in move_unreachab…
6a32de1
…le() (python#159154)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sergey-miryanov sergey-miryanov sergey-miryanov approved these changes
@nascheme nascheme Awaiting requested review from nascheme

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@pablogsal @sergey-miryanov
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.