]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-112529: Make the GC scheduling thread-safe (#114880)
authorSam Gross <colesbury@gmail.com>
Fri, 16 Feb 2024 16:22:27 +0000 (11:22 -0500)
committerGitHub <noreply@github.com>
Fri, 16 Feb 2024 16:22:27 +0000 (11:22 -0500)
commitb24c9161a651f549ed48f4b4dba8996fe9cc4e09
tree549acacced5ca0b1923e0df94b40ef633c6cdf8f
parentf92857a93016aa26ba93959d2bdb690ef52e7f07
gh-112529: Make the GC scheduling thread-safe (#114880)

The GC keeps track of the number of allocations (less deallocations)
since the last GC. This buffers the count in thread-local state and uses
atomic operations to modify the per-interpreter count. The thread-local
buffering avoids contention on shared state.

A consequence is that the GC scheduling is not as precise, so
"test_sneaky_frame_object" is skipped because it requires that the GC be
run exactly after allocating a frame object.
Include/internal/pycore_gc.h
Include/internal/pycore_tstate.h
Lib/test/test_frame.py
Lib/test/test_gc.py
Modules/gcmodule.c
Objects/typeobject.c
Python/gc_free_threading.c