diff options
author | Mark Shannon <mark@hotpy.org> | 2024-03-20 08:54:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 08:54:42 (GMT) |
commit | 15309329b65a285cb7b3071f0f08ac964b61411b (patch) | |
tree | 83b5be564755d7ea396c76eda29e6d33faf535d9 /Modules/gcmodule.c | |
parent | d5ebf8b71fd18d7a1f2f6b670a2c18749dc2b55e (diff) | |
download | cpython-15309329b65a285cb7b3071f0f08ac964b61411b.zip cpython-15309329b65a285cb7b3071f0f08ac964b61411b.tar.gz cpython-15309329b65a285cb7b3071f0f08ac964b61411b.tar.bz2 |
GH-108362: Incremental Cycle GC (GH-116206)
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 9807d2e..3320e54 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -158,17 +158,12 @@ gc_set_threshold_impl(PyObject *module, int threshold0, int group_right_1, { GCState *gcstate = get_gc_state(); - gcstate->generations[0].threshold = threshold0; + gcstate->young.threshold = threshold0; if (group_right_1) { - gcstate->generations[1].threshold = threshold1; + gcstate->old[0].threshold = threshold1; } if (group_right_2) { - gcstate->generations[2].threshold = threshold2; - - /* generations higher than 2 get the same threshold */ - for (int i = 3; i < NUM_GENERATIONS; i++) { - gcstate->generations[i].threshold = gcstate->generations[2].threshold; - } + gcstate->old[1].threshold = threshold2; } Py_RETURN_NONE; } @@ -185,9 +180,9 @@ gc_get_threshold_impl(PyObject *module) { GCState *gcstate = get_gc_state(); return Py_BuildValue("(iii)", - gcstate->generations[0].threshold, - gcstate->generations[1].threshold, - gcstate->generations[2].threshold); + gcstate->young.threshold, + gcstate->old[0].threshold, + 0); } /*[clinic input] @@ -207,14 +202,14 @@ gc_get_count_impl(PyObject *module) struct _gc_thread_state *gc = &tstate->gc; // Flush the local allocation count to the global count - _Py_atomic_add_int(&gcstate->generations[0].count, (int)gc->alloc_count); + _Py_atomic_add_int(&gcstate->young.count, (int)gc->alloc_count); gc->alloc_count = 0; #endif return Py_BuildValue("(iii)", - gcstate->generations[0].count, - gcstate->generations[1].count, - gcstate->generations[2].count); + gcstate->young.count, + gcstate->old[gcstate->visited_space].count, + gcstate->old[gcstate->visited_space^1].count); } /*[clinic input] |