◐ Shell
clean mode source ↗

GH-148726: Add heap_size to generational GC by sergey-miryanov · Pull Request #149195 · python/cpython

@sergey-miryanov sergey-miryanov changed the title Add heap_size to generational GC GH-148726: Add heap_size to generational GC

Apr 30, 2026

zanieb

@nascheme

nascheme

@bedevere-bot

@sergey-miryanov

Good catch by @DinoV in #149241. I believe we should cherry-pick those commits here.

@hugovk

Good catch by @DinoV in #149241. I believe we should cherry-pick those commits here.

Good idea.

Co-authored-by: Dino Viehland <dinoviehland@meta.com>
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>

@sergey-miryanov

@zanieb @nascheme Could you please take another look? I've ported the 3.14 heap_size changes and included heap_size in get_gc_stats.

@DinoV FYI, the layout of _gc_runtime_state will change since we moved generation_stats to the heap.

@nascheme

I'd say for 3.15 we don't need the two dummy members and we could move generation0 back to it's old position. Preserving the member offsets should not be required for 3.15, right?

@sergey-miryanov

Since we're moving the stats to the heap, all subsequent offsets will shift anyway. There's no need to keep the dummy members.

I thought this would simplify backports if needed.

I'm happy to remove the dummy members and restore generation0 if you think that's cleaner.

@nascheme

I'm happy to remove the dummy members and restore generation0 if you think that's cleaner.

I think it's better to remove the dummy members. You don't have to restore generation0 since the code looks fine without that member. Other than that, this PR looks fine to me.

…ov/cpython into feat/gc-gen-3.15+heap_size

@sergey-miryanov

pablogsal

Choose a reason for hiding this comment

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

@sergey-miryanov