Skip to content

Commit c7683a4

Browse files
committed
Explain work to do calculation
1 parent 9cfb5f0 commit c7683a4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Python/gc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,10 +1552,17 @@ mark_at_start(PyThreadState *tstate)
15521552
static Py_ssize_t
15531553
assess_work_to_do(GCState *gcstate)
15541554
{
1555-
/* The amount of work we want to do depends on two things.
1555+
/* The amount of work we want to do depends on three things.
15561556
* 1. The number of new objects created
15571557
* 2. The growth in heap size since the last collection
15581558
* 3. The heap size (up to the number of new objects, to avoid quadratic effects)
1559+
*
1560+
* For a steady state heap, the amount of work to do is three times the number
1561+
* of new objects added to the heap. This ensures that we stay ahead in the
1562+
* worst case of all new objects being garbage.
1563+
*
1564+
* This could be improved by tracking survival rates, but it is still a
1565+
* large improvement on the non-marking approach.
15591566
*/
15601567
Py_ssize_t scale_factor = gcstate->old[0].threshold;
15611568
if (scale_factor < 2) {

0 commit comments

Comments
 (0)