@@ -523,15 +523,15 @@ but doing too much work slows down execution.
523523
524524To work out how much work we need to do, consider a heap with ` L ` live objects
525525and ` G0 ` garbage objects at the start of a full scavenge and ` G1 ` garbage objects
526- at the end of the scavenge. We don't want amount of garbage to grow, ` G1 ≤ G0 ` , and
526+ at the end of the scavenge. We don't want the amount of garbage to grow, ` G1 ≤ G0 ` , and
527527we don't want too much garbage (say 1/3 of the heap maximum), ` G0 ≤ L/2 ` .
528528For each full scavenge we must visit all objects, ` T == L + G0 + G1 ` , during which
529529` G1 ` garbage objects are created.
530530
531531The number of new objects created ` N ` must be at least the new garbage created, ` N ≥ G1 ` ,
532532assuming that the number of live objects remains roughly constant.
533533If we set ` T == 4*N ` we get ` T > 4*G1 ` and ` T = L + G0 + G1 ` => ` L + G0 > 3G1 `
534- For a steady state heap ` G0 == G1 ` we get ` L > 2G ` and the desired garbage ratio.
534+ For a steady state heap ( ` G0 == G1 ` ) we get ` L > 2G0 ` and the desired garbage ratio.
535535
536536In other words, to keep the garbage fraction to 1/3 or less we need to visit
5375374 times as many objects as are newly created.
@@ -544,11 +544,11 @@ Everything in `M` is live, so `I ≥ G0` and in practice `I` is closer to `G0 +
544544
545545If we choose the amount of work done such that ` 2*M + I == 6N ` then we can do
546546less work in most cases, but are still guaranteed to keep up.
547- Since ` I ≥ G0 + G1 ` (not strictly true, but close enough)
548- ` T == M + I == (6N + I)/2 ` and ` (6N + I)/2 ≥ 4G ` , so we can keep up.
547+ Since ` I ≳ G0 + G1 ` (not strictly true, but close enough)
548+ ` T == M + I == (6N + I)/2 ` and ` (6N + I)/2 ≳ 4G ` , so we can keep up.
549549
550550The reason that this improves performance is that ` M ` is usually much larger
551- than ` I ` Suppose ` M == 10I ` , then ` T ≅ 3N ` .
551+ than ` I ` . If ` M == 10I ` , then ` T ≅ 3N ` .
552552
553553Finally, instead of using a fixed multiple of 8, we gradually increase it as the
554554heap grows. This avoids wasting work for small heaps and during startup.
0 commit comments