summaryrefslogtreecommitdiffstats
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
authorT. Wouters <thomas@python.org>2024-09-30 21:27:29 (GMT)
committerGitHub <noreply@github.com>2024-09-30 21:27:29 (GMT)
commite0eb44ad49926dd131dc639f5506c6769e45b4eb (patch)
tree200d0b3773a61d1001f4775dada2afd67aa0f0c6 /Modules/gcmodule.c
parentbc1fae89af9df3888fab670f83b7aed8afe5a9f5 (diff)
downloadcpython-e0eb44ad49926dd131dc639f5506c6769e45b4eb.zip
cpython-e0eb44ad49926dd131dc639f5506c6769e45b4eb.tar.gz
cpython-e0eb44ad49926dd131dc639f5506c6769e45b4eb.tar.bz2
[3.13] GH-124567: Revert the Incremental GC in 3.13 (#124770)
Revert the incremental GC in 3.13, since it's not clear that without further turning, the benefits outweigh the costs. Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 57e4aae..b57a1c9 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -158,12 +158,17 @@ gc_set_threshold_impl(PyObject *module, int threshold0, int group_right_1,
{
GCState *gcstate = get_gc_state();
- gcstate->young.threshold = threshold0;
+ gcstate->generations[0].threshold = threshold0;
if (group_right_1) {
- gcstate->old[0].threshold = threshold1;
+ gcstate->generations[1].threshold = threshold1;
}
if (group_right_2) {
- gcstate->old[1].threshold = threshold2;
+ 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;
+ }
}
Py_RETURN_NONE;
}
@@ -180,9 +185,9 @@ gc_get_threshold_impl(PyObject *module)
{
GCState *gcstate = get_gc_state();
return Py_BuildValue("(iii)",
- gcstate->young.threshold,
- gcstate->old[0].threshold,
- 0);
+ gcstate->generations[0].threshold,
+ gcstate->generations[1].threshold,
+ gcstate->generations[2].threshold);
}
/*[clinic input]
@@ -202,14 +207,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->young.count, (int)gc->alloc_count);
+ _Py_atomic_add_int(&gcstate->generations[0].count, (int)gc->alloc_count);
gc->alloc_count = 0;
#endif
return Py_BuildValue("(iii)",
- gcstate->young.count,
- gcstate->old[gcstate->visited_space].count,
- gcstate->old[gcstate->visited_space^1].count);
+ gcstate->generations[0].count,
+ gcstate->generations[1].count,
+ gcstate->generations[2].count);
}
/*[clinic input]