FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-159437: Count garbage during weakref cleanup by mfalco-oai · Pull Request #159598 · python/cpython · GitHub

Repository navigation

gh-159437: Count garbage during weakref cleanup - #159598

Draft
mfalco-oai wants to merge 3 commits into
python:mainfrom
mfalco-oai:mfalco-oai/gh-159437-gc-count
Draft

mfalco-oai wants to merge 3 commits into
python:mainfrom
mfalco-oai:mfalco-oai/gh-159437-gc-count

Conversation

mfalco-oai commented Oct 16, 2026 •
edited
Loading

Copy link
Copy Markdown

With this optimization the GIL collector counts collectable objects during late weakref cleanup. This removes the separate gc_list_size() walk over the same list.

Performance

Before is #159587 (ff1acf0a); after is this PR at 70bc7962. Both builds use -falign-functions=64.

gc_collect_self_lists collects 1,000,000 one-element lists that refer to themselves.

CPU Before After Change (95% interval) Result
AMD 81.805 ms 78.318 ms −4.26% [−13.49%, +6.23%] Inconclusive
ARM 69.844 ms 64.783 ms −7.25% [−7.98%, −6.48%] Inconclusive (A/A failed)

Benchmarks: python/pyperformance#496

pablogsal left a comment •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The counting change seems independent of the callback refactor. clear_weakrefs() already walks the final collectable list without running Python, so returning its size doesn't need the new callback helper or list selection. Let's keep this change seperate if that refactor gets reworked.

mfalco-oai force-pushed the mfalco-oai/gh-159437-gc-count branch from 768f2d6 to 934dc3b Compare October 19, 2026 22:23
mfalco-oai force-pushed the mfalco-oai/gh-159437-gc-count branch from 934dc3b to 70bc796 Compare October 21, 2026 13:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL