Skip to content

Commit be636c9

Browse files
committed
Refactor work to do calculation
1 parent bb51b19 commit be636c9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Python/gc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,14 +1548,15 @@ assess_work_to_do(GCState *gcstate)
15481548
* This could be improved by tracking survival rates, but it is still a
15491549
* large improvement on the non-marking approach.
15501550
*/
1551-
Py_ssize_t scale_factor = gcstate->old[0].threshold;
1551+
intptr_t scale_factor = gcstate->old[0].threshold;
15521552
if (scale_factor < 2) {
15531553
scale_factor = 2;
15541554
}
1555-
Py_ssize_t new_objects = gcstate->young.count;
1556-
Py_ssize_t heap_fraction = gcstate->heap_size / SCAN_RATE_DIVISOR / scale_factor;
1557-
if (heap_fraction > new_objects*2) {
1558-
heap_fraction = new_objects*2;
1555+
intptr_t new_objects = gcstate->young.count;
1556+
intptr_t max_heap_fraction = new_objects * 3/2;
1557+
intptr_t heap_fraction = gcstate->heap_size / SCAN_RATE_DIVISOR / scale_factor;
1558+
if (heap_fraction > max_heap_fraction) {
1559+
heap_fraction = max_heap_fraction;
15591560
}
15601561
gcstate->young.count = 0;
15611562
return new_objects + heap_fraction;

0 commit comments

Comments
 (0)