Skip to content

Commit 8262bf0

Browse files
committed
More tweaking of thresholds
1 parent ba20c7c commit 8262bf0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/gc.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ gc_list_set_space(PyGC_Head *list, int space)
12831283
* K > 2. Higher values of K mean that the old space is
12841284
* scanned more rapidly.
12851285
*/
1286-
#define SCAN_RATE_DIVISOR 10
1286+
#define SCAN_RATE_DIVISOR 5
12871287

12881288
static void
12891289
add_stats(GCState *gcstate, int gen, struct gc_collection_stats *stats)
@@ -1566,7 +1566,7 @@ assess_work_to_do(GCState *gcstate)
15661566
scale_factor = 2;
15671567
}
15681568
intptr_t new_objects = gcstate->young.count;
1569-
intptr_t max_heap_fraction = new_objects*2;
1569+
intptr_t max_heap_fraction = new_objects*5;
15701570
intptr_t heap_fraction = gcstate->heap_size / SCAN_RATE_DIVISOR / scale_factor;
15711571
if (heap_fraction > max_heap_fraction) {
15721572
heap_fraction = max_heap_fraction;
@@ -1585,7 +1585,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
15851585
if (gcstate->phase == GC_PHASE_MARK) {
15861586
Py_ssize_t objects_marked = mark_at_start(tstate);
15871587
GC_STAT_ADD(1, objects_transitively_reachable, objects_marked);
1588-
gcstate->work_to_do -= objects_marked;
1588+
gcstate->work_to_do -= objects_marked*2;
15891589
validate_spaces(gcstate);
15901590
return;
15911591
}
@@ -1597,7 +1597,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
15971597
}
15981598
intptr_t objects_marked = mark_stacks(tstate->interp, visited, gcstate->visited_space, false);
15991599
GC_STAT_ADD(1, objects_transitively_reachable, objects_marked);
1600-
gcstate->work_to_do -= objects_marked;
1600+
gcstate->work_to_do -= objects_marked*2;
16011601
gc_list_set_space(&gcstate->young.head, gcstate->visited_space);
16021602
PyGC_Head increment;
16031603
gc_list_init(&increment);
@@ -1608,7 +1608,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
16081608
Py_ssize_t increment_size = move_all_transitively_reachable(&working, &increment, gcstate->visited_space);
16091609
gc_list_validate_space(&increment, gcstate->visited_space);
16101610
assert(working.top == NULL);
1611-
while (increment_size < gcstate->work_to_do * 2) {
1611+
while (increment_size < gcstate->work_to_do) {
16121612
if (gc_list_is_empty(not_visited)) {
16131613
break;
16141614
}
@@ -1628,7 +1628,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
16281628
gc_collect_region(tstate, &increment, &survivors, stats);
16291629
gc_list_merge(&survivors, visited);
16301630
assert(gc_list_is_empty(&increment));
1631-
gcstate->work_to_do -= increment_size/2;
1631+
gcstate->work_to_do -= increment_size;
16321632

16331633
add_stats(gcstate, 1, stats);
16341634
if (gc_list_is_empty(not_visited)) {

0 commit comments

Comments
 (0)