◐ Shell
clean mode source ↗

GH-146527: Add get_gc_stats function to _remote_debugging by sergey-miryanov · Pull Request #148071 · python/cpython

Thanks a lot for the great work on this @sergey-miryanov! I pushed a set of follow-up commits on top because we are getting close to beta freeze and I wanted to make sure this lands in a solid shape.

The follow-ups validate the remote GC stats offset and reject incompatible remote layoutsinstead of accepting short reads, reject a NULL remote GC stats pointer, record timestamps in the free-threaded GC path, and document why ts_stop is published last. I also moved the non-trivial GC stats implementation out of the header into gc_stats.c and updated the POSIX and Windows build files for that split. The API now returns _remote_debugging.GCStatsInfo structseq objects instead of dictionaries, matching the rest of _remote_debugging, and the docs/Clinic text now describes the fields and errors properly. I dropped heap_size from the exposed docs since it is not actually exposed by the current stats layout.

On the test side, I renamed the test file to test_gc_stats.py, added timestamp and field coverage, updated the assertions for GCStatsInfo, and changed the workload to allocate tracked self-referential containers so the candidate counts advance deterministically.