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-128807: Add marking phase for free-threaded cyclic GC#128808

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

Merged
nascheme merged 20 commits intopython:mainfromnascheme:nogil-gc-mark-alive
Jan 15, 2025

Conversation

@nascheme
Copy link
Member

@naschemenascheme commentedJan 14, 2025
edited
Loading

This is conceptually similar to the phase that was added to the non-free-threaded GC. Start with a set of known root objects, like sysdict and mark all objects reachable from those (revealed by the tp_traverse method) as "alive". We know anything marked alive cannot be garbage and can be excluded from the regular cyclic GC process. For most programs, this saves a moderate amount of computation since the marking pass is relatively cheaper per object.

Ifgc.freeze() is used, it's unlikely that this marking phase will be a win since it's expected that the majority of objects will be frozen. Disable the marking phase if freeze is used.

Seegh-126491 for the non-free-threaded version of this technique.

pyperformanceresults vs merge base. I suspect the slowdown on some benchmarks is not real. For example, regex_v8 should not be slower.

Here are the pyperformance results for a bare-metal AMD Ryzen machine. It does not show a slowdown on regex_v8, for example.

To better show the expected improvement, I ran a "sphinx build" benchmark, like ingh-124567. Results are:

oldnew
GC collections3838
long-lived objects586,986585,730
total run time3.24 s3.03 s
mark phase time0.00 s0.16 s
total gc time0.72 s0.57 s

corona10, thinkwelltwd, colesbury, mpage, AA-Turner, dolfinus, and sergey-miryanov reacted with hooray emoji
@ghost
Copy link

ghost commentedJan 14, 2025
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

If the object is already marked as reachable, we shouldn't traverse itagain.
These are not strictly needed, simplify PR.
More code cleanup (better names, comments, simplify error handling).Fix bug in that "alive" bit must be checked in mark_alive_stack_push()to avoid visiting already visited objects.
Make sure we still do this optimization.  There is also a unit test thatchecks for this.
@naschemenascheme marked this pull request as ready for reviewJanuary 14, 2025 18:12
Copy link
Contributor

@colesburycolesbury left a comment

Choose a reason for hiding this comment

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

Looks great! A few comments below

Use gc_abort_mark_alive() helper in case of OOM.  In addition tofreeing the stack, we need to ensure that no object has the alive bitset on it.  This also adding missing error handling in the case thatpropagate_alive_bits() fails.
Copy link
Contributor

@colesburycolesbury left a comment

Choose a reason for hiding this comment

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

LGTM

nascheme reacted with laugh emoji
@naschemenascheme merged commit080f444 intopython:mainJan 15, 2025
45 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kumaraditya303kumaraditya303kumaraditya303 left review comments

@colesburycolesburycolesbury approved these changes

Assignees

No one assigned

Labels

performancePerformance or resource usagetopic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@nascheme@colesbury@kumaraditya303

[8]ページ先頭

©2009-2025 Movatter.jp