]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-114746: Avoid quadratic behavior in free-threaded GC (GH-114817)
authorSam Gross <colesbury@gmail.com>
Thu, 1 Feb 2024 09:26:23 +0000 (04:26 -0500)
committerGitHub <noreply@github.com>
Thu, 1 Feb 2024 09:26:23 +0000 (10:26 +0100)
commite6d6d5dcc00af50446761b0c4d20bd6e92380135
tree77832c15b67d591317682f916839c78a7f10b0d8
parent5ce193e65a7e6f239337a8c5305895cf8a4d2726
gh-114746: Avoid quadratic behavior in free-threaded GC (GH-114817)

The free-threaded build's GC implementation is non-generational, but was
scheduled as if it were collecting a young generation leading to
quadratic behavior. This increases the minimum threshold and scales it
to the number of live objects as we do for the old generation in the
default build.

Note that the scheduling is still not thread-safe without the GIL. Those
changes will come in later PRs.

A few tests, like "test_sneaky_frame_object" rely on prompt scheduling
of the GC. For now, to keep that test passing, we disable the scaled
threshold after calls like `gc.set_threshold(1, 0, 0)`.
Python/gc_free_threading.c