Skip to content

Commit e46d17d

Browse files
committed
design: add initial conditions section to GC pacer redesign
I realized I neglected to talk about initial conditions, even though all the simulations clearly set *something*. For golang/go#44167. Change-Id: Ia1727d5c068847e9192bf87bc1b6a5f0bb832303 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/295509 Reviewed-by: Michael Pratt <[email protected]>
1 parent 34a9c69 commit e46d17d

39 files changed

+48
-1
lines changed

design/44167-gc-pacer-redesign.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,27 @@ condition to include these limits.
565565
It's not important to put these limits in the rest of the pacer because it no
566566
longer tries to compute the trigger point ahead of time.
567567

568+
### Initial conditions
569+
570+
Like today, the pacer has to start somewhere for the first GC.
571+
I propose we carry forward what we already do today: set the trigger point at
572+
7/8ths of the first heap goal, which will always be the minimum heap size.
573+
If GC 1 is the first GC, then in terms of the math above, we choose to avoid
574+
defining ![`M_0`](44167/inl27.png), and instead directly define
575+
576+
![Equation 8](44167/eqn8.png)
577+
578+
The definition of ![`P_0`](44167/inl28.png) is necessary for the GC assist
579+
pacer.
580+
581+
Furthermore, the PI controller's state will be initialized to zero otherwise.
582+
583+
These choices are somewhat arbitrary, but the fact is that the pacer has no
584+
knowledge of the progam's past behavior for the first GC.
585+
Naturally the behavior of the GC will always be a little odd, but it should, in
586+
general, stabilize quite quickly (note that this is the case in each scenario
587+
for the [simulations](#simulations).
588+
568589
## A note about CPU utilization
569590

570591
This document uses the term "GC CPU utilization" quite frequently, but so far
@@ -591,7 +612,7 @@ time all goroutines spend in GC assists.
591612
The latter is computed directly, but is just the difference between the start
592613
and end time in the critical section; it does not try to account for context
593614
switches forced by the underlying system, or anything like that.
594-
Now take this value we just computed and divide it by ![`T`](44167/inl27.png).
615+
Now take this value we just computed and divide it by ![`T`](44167/inl29.png).
595616
That's our GC CPU utilization.
596617

597618
This approximation is mostly accurate in the common case, but is prone to skew

design/44167/eqn1.png

0 Bytes
Loading

design/44167/eqn2.png

0 Bytes
Loading

design/44167/eqn3.png

0 Bytes
Loading

design/44167/eqn4.png

0 Bytes
Loading

design/44167/eqn5.png

0 Bytes
Loading

design/44167/eqn6.png

0 Bytes
Loading

design/44167/eqn7.png

0 Bytes
Loading

design/44167/eqn8.png

389 Bytes
Loading

design/44167/gc-pacer-redesign.src.md

+26
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,32 @@ condition to include these limits.
573573
It's not important to put these limits in the rest of the pacer because it no
574574
longer tries to compute the trigger point ahead of time.
575575

576+
### Initial conditions
577+
578+
Like today, the pacer has to start somewhere for the first GC.
579+
I propose we carry forward what we already do today: set the trigger point at
580+
7/8ths of the first heap goal, which will always be the minimum heap size.
581+
If GC 1 is the first GC, then in terms of the math above, we choose to avoid
582+
defining `$M_0$`, and instead directly define
583+
584+
```render-latex
585+
\begin{aligned}
586+
N_1 & = \textrm{minimum heap size} \\
587+
T_1 & = \frac{7}{8} N_1 \\
588+
P_0 & = 0
589+
\end{aligned}
590+
```
591+
592+
The definition of `$P_0$` is necessary for the GC assist pacer.
593+
594+
Furthermore, the PI controller's state will be initialized to zero otherwise.
595+
596+
These choices are somewhat arbitrary, but the fact is that the pacer has no
597+
knowledge of the progam's past behavior for the first GC.
598+
Naturally the behavior of the GC will always be a little odd, but it should, in
599+
general, stabilize quite quickly (note that this is the case in each scenario
600+
for the [simulations](#simulations).
601+
576602
## A note about CPU utilization
577603

578604
This document uses the term "GC CPU utilization" quite frequently, but so far

design/44167/inl1.png

0 Bytes
Loading

design/44167/inl10.png

0 Bytes
Loading

design/44167/inl11.png

0 Bytes
Loading

design/44167/inl12.png

0 Bytes
Loading

design/44167/inl13.png

0 Bytes
Loading

design/44167/inl14.png

0 Bytes
Loading

design/44167/inl15.png

0 Bytes
Loading

design/44167/inl16.png

0 Bytes
Loading

design/44167/inl17.png

0 Bytes
Loading

design/44167/inl18.png

0 Bytes
Loading

design/44167/inl19.png

0 Bytes
Loading

design/44167/inl2.png

0 Bytes
Loading

design/44167/inl20.png

0 Bytes
Loading

design/44167/inl21.png

0 Bytes
Loading

design/44167/inl22.png

0 Bytes
Loading

design/44167/inl23.png

0 Bytes
Loading

design/44167/inl24.png

0 Bytes
Loading

design/44167/inl25.png

0 Bytes
Loading

design/44167/inl26.png

0 Bytes
Loading

design/44167/inl27.png

478 Bytes
Loading

design/44167/inl28.png

439 Bytes
Loading

design/44167/inl29.png

389 Bytes
Loading

design/44167/inl3.png

0 Bytes
Loading

design/44167/inl4.png

0 Bytes
Loading

design/44167/inl5.png

0 Bytes
Loading

design/44167/inl6.png

0 Bytes
Loading

design/44167/inl7.png

0 Bytes
Loading

design/44167/inl8.png

0 Bytes
Loading

design/44167/inl9.png

0 Bytes
Loading

0 commit comments

Comments
 (0)