Skip to content

Bound runsc GOMAXPROCS and scale initial GOGC during init on >128-CPU hosts. - #16769

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl1010065697
Open

copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl1010065697

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Bound runsc GOMAXPROCS and scale initial GOGC during init on >128-CPU hosts.

The Go runtime automatically makes processor structs up to the number
of cores that are visible (around 16 kibs per processor struct).
Notably, Go's first gc collection cycle defaults to ~3.81 mibs, so
on machines with >128 cpus, the structs get us close to that limit,
and init()s can get us past that limit before the main function of a
command starts.

The effects are felt most on very short lived commands, where the time
spent in the GC cycle is greater than the time spent exec'ing the command.

So:

  • Lower GOMAXPROCS to 8 at the start of package init
  • Scale initial GOGC (when bootstrap GC hasn't already run) to offset retained
    runtime.p spans
  • Restore the pre-init GOGC in long-lived allocating subcommands (gofer,
    non-stream port-forward, and streaming events)

Isolated GCE c4-standard-192 COS benchmarks (192 vCPUs, n=20 interleaved):

Expand for full GCE c4-standard-192 COS benchstat output

Arms (n=20 interleaved; n=16 for Docker Startup*/Size*):

  • baseline: clean main
  • autoresearcher: early GOMAXPROCS=8 above 128 CPUs without initial GOGC scaling
  • optimized: this change standalone
  • stacked: this change stacked on gofer GOMAXPROCS bounding
goos: linux
goarch: amd64
pkg: gvisor.dev/gvisor/runsc/cli/maxprocs
                            │   baseline    │            autoresearcher            │              optimized              │               stacked               │
                            │    sec/op     │    sec/op     vs base                │   sec/op     vs base                │   sec/op     vs base                │
RunscState/cpus=2              2.776m ±  1%    2.748m ± 3%        ~ (p=0.799 n=20)   2.729m ± 2%        ~ (p=0.242 n=20)   2.788m ± 2%        ~ (p=0.383 n=20)
RunscState/cpus=4              2.895m ±  2%    2.831m ± 4%        ~ (p=0.341 n=20)   2.831m ± 2%        ~ (p=0.114 n=20)   2.922m ± 2%        ~ (p=0.289 n=20)
RunscState/cpus=16             2.713m ±  1%    2.702m ± 3%        ~ (p=0.461 n=20)   2.724m ± 2%        ~ (p=0.841 n=20)   2.744m ± 2%        ~ (p=0.201 n=20)
RunscState/cpus=48             2.816m ±  4%    2.772m ± 4%        ~ (p=0.678 n=20)   2.737m ± 3%        ~ (p=0.157 n=20)   2.842m ± 4%        ~ (p=0.341 n=20)
RunscState/cpus=96             3.265m ±  3%    3.215m ± 3%        ~ (p=0.602 n=20)   3.143m ± 4%        ~ (p=0.086 n=20)   3.269m ± 4%        ~ (p=0.114 n=20)
RunscState/cpus=128            3.268m ±  3%    3.287m ± 5%        ~ (p=0.429 n=20)   3.225m ± 5%        ~ (p=0.925 n=20)   3.241m ± 3%        ~ (p=0.947 n=20)
RunscState/cpus=129            3.197m ±  8%    3.484m ± 2%   +8.95% (p=0.000 n=20)   3.490m ± 4%   +9.15% (p=0.000 n=20)   3.536m ± 4%  +10.60% (p=0.000 n=20)
RunscState/cpus=144            3.770m ± 12%    3.768m ± 6%        ~ (p=0.799 n=20)   3.673m ± 4%        ~ (p=0.904 n=20)   3.725m ± 2%        ~ (p=0.799 n=20)
RunscState/cpus=160            7.545m ±  5%    4.368m ± 3%  -42.11% (p=0.000 n=20)   3.835m ± 6%  -49.18% (p=0.000 n=20)   3.940m ± 4%  -47.79% (p=0.000 n=20)
RunscState/cpus=192           11.514m ±  3%    6.156m ± 4%  -46.53% (p=0.000 n=20)   4.259m ± 1%  -63.01% (p=0.000 n=20)   4.253m ± 3%  -63.06% (p=0.000 n=20)
RunscState/quota=150           6.079m ± 13%    4.433m ± 4%  -27.07% (p=0.000 n=20)   4.352m ± 2%  -28.40% (p=0.000 n=20)   4.392m ± 2%  -27.75% (p=0.000 n=20)
ContainerLifecycle/cpus=16     60.83m ±  1%    60.46m ± 1%        ~ (p=0.461 n=20)   60.34m ± 1%        ~ (p=0.211 n=20)   60.92m ± 1%        ~ (p=0.355 n=20)
ContainerLifecycle/cpus=96     82.32m ±  5%    82.08m ± 3%        ~ (p=0.779 n=20)   81.10m ± 4%        ~ (p=0.096 n=20)   83.78m ± 3%        ~ (p=0.242 n=20)
ContainerLifecycle/cpus=128    74.94m ±  3%    75.03m ± 2%        ~ (p=1.000 n=20)   75.25m ± 5%        ~ (p=0.341 n=20)   76.27m ± 5%        ~ (p=0.947 n=20)
ContainerLifecycle/cpus=160   108.36m ±  3%    84.59m ± 3%  -21.93% (p=0.000 n=20)   76.73m ± 2%  -29.19% (p=0.000 n=20)   78.14m ± 3%  -27.90% (p=0.000 n=20)
ContainerLifecycle/cpus=192   155.25m ±  3%   102.14m ± 4%  -34.21% (p=0.000 n=20)   92.11m ± 2%  -40.67% (p=0.000 n=20)   93.67m ± 4%  -39.67% (p=0.000 n=20)
StartupEmpty-192               373.7m ±  5%    367.6m ± 5%        ~ (p=0.515 n=16)   369.7m ± 4%        ~ (p=0.616 n=16)   368.9m ± 7%        ~ (p=0.361 n=16)
StartupNginx-192               654.0m ±  3%    667.9m ± 5%        ~ (p=0.867 n=16)   651.2m ± 3%        ~ (p=0.669 n=16)   659.4m ± 3%        ~ (p=0.956 n=16)
SizeNginx-192                  873.4m ±  3%    861.9m ± 2%        ~ (p=0.752 n=16)   866.7m ± 3%        ~ (p=0.867 n=16)   866.7m ± 5%        ~ (p=0.838 n=16)
geomean                        20.07m          17.93m       -10.69%                  17.17m       -14.46%                  17.45m       -13.07%

                     │   baseline   │           autoresearcher           │             optimized              │              stacked               │
                     │  cpu-ms/op   │ cpu-ms/op   vs base                │ cpu-ms/op   vs base                │ cpu-ms/op   vs base                │
RunscState/cpus=2       2.636 ±  2%   2.628 ± 3%        ~ (p=0.857 n=20)   2.617 ± 2%        ~ (p=0.703 n=20)   2.664 ± 1%        ~ (p=0.433 n=20)
RunscState/cpus=4       2.982 ±  2%   2.938 ± 4%        ~ (p=0.344 n=20)   2.927 ± 2%   -1.83% (p=0.042 n=20)   2.987 ± 2%        ~ (p=0.836 n=20)
RunscState/cpus=16      2.873 ±  1%   2.880 ± 1%        ~ (p=0.683 n=20)   2.883 ± 2%        ~ (p=0.683 n=20)   2.912 ± 2%        ~ (p=0.176 n=20)
RunscState/cpus=48      3.050 ±  4%   2.999 ± 5%        ~ (p=0.888 n=20)   2.954 ± 3%        ~ (p=0.304 n=20)   3.085 ± 4%        ~ (p=0.425 n=20)
RunscState/cpus=96      3.567 ±  3%   3.515 ± 2%        ~ (p=0.703 n=20)   3.450 ± 2%        ~ (p=0.116 n=20)   3.569 ± 3%        ~ (p=0.142 n=20)
RunscState/cpus=128     3.508 ±  3%   3.534 ± 4%        ~ (p=0.774 n=20)   3.492 ± 3%        ~ (p=0.941 n=20)   3.500 ± 2%        ~ (p=0.836 n=20)
RunscState/cpus=129     3.489 ±  6%   3.734 ± 3%   +7.02% (p=0.002 n=20)   3.755 ± 4%   +7.63% (p=0.001 n=20)   3.814 ± 4%   +9.33% (p=0.000 n=20)
RunscState/cpus=144     4.752 ± 24%   4.046 ± 4%        ~ (p=0.529 n=20)   3.962 ± 3%        ~ (p=0.465 n=20)   3.997 ± 3%        ~ (p=0.529 n=20)
RunscState/cpus=160    14.334 ±  6%   5.103 ± 4%  -64.40% (p=0.000 n=20)   4.139 ± 4%  -71.12% (p=0.000 n=20)   4.197 ± 4%  -70.72% (p=0.000 n=20)
RunscState/cpus=192    23.596 ±  4%   7.796 ± 2%  -66.96% (p=0.000 n=20)   4.574 ± 4%  -80.62% (p=0.000 n=20)   4.488 ± 4%  -80.98% (p=0.000 n=20)
RunscState/quota=150   10.531 ±  9%   4.814 ± 4%  -54.28% (p=0.000 n=20)   4.654 ± 2%  -55.81% (p=0.000 n=20)   4.697 ± 2%  -55.40% (p=0.000 n=20)
geomean                 5.019         3.802       -24.25%                  3.521       -29.85%                  3.571       -28.85%

                            │   baseline    │            autoresearcher             │               optimized               │                stacked                │
                            │ cli-cpu-ms/op │ cli-cpu-ms/op  vs base                │ cli-cpu-ms/op  vs base                │ cli-cpu-ms/op  vs base                │
ContainerLifecycle/cpus=16       37.33 ± 1%     37.37 ±  1%        ~ (p=0.952 n=20)      36.80 ± 2%        ~ (p=0.183 n=20)      37.68 ± 1%        ~ (p=0.149 n=20)
ContainerLifecycle/cpus=96       51.17 ± 4%     49.33 ±  7%        ~ (p=0.445 n=20)      48.77 ± 3%   -4.70% (p=0.012 n=20)      50.56 ± 4%        ~ (p=0.820 n=20)
ContainerLifecycle/cpus=128      66.74 ± 9%     69.65 ± 10%        ~ (p=0.758 n=20)      67.19 ± 7%        ~ (p=0.583 n=20)      68.83 ± 8%        ~ (p=1.000 n=20)
ContainerLifecycle/cpus=160     151.24 ± 4%     71.96 ±  2%  -52.42% (p=0.000 n=20)      52.62 ± 2%  -65.21% (p=0.000 n=20)      53.20 ± 4%  -64.83% (p=0.000 n=20)
ContainerLifecycle/cpus=192     248.93 ± 5%     85.47 ±  5%  -65.67% (p=0.000 n=20)      61.20 ± 5%  -75.41% (p=0.000 n=20)      62.54 ± 2%  -74.88% (p=0.000 n=20)
geomean                          86.35          60.19        -30.30%                     52.22       -39.52%                     53.45       -38.10%

                        │   baseline   │            autoresearcher            │              optimized              │               stacked                │
                        │   pss-B/op   │   pss-B/op    vs base                │   pss-B/op    vs base               │   pss-B/op    vs base                │
GoferFootprint/cpus=192   17.81Mi ± 0%   15.94Mi ± 1%  -10.48% (p=0.000 n=20)   16.10Mi ± 1%  -9.61% (p=0.000 n=20)   11.87Mi ± 1%  -33.34% (p=0.000 n=20)

                        │   baseline    │            autoresearcher             │               optimized               │                stacked                │
                        │ rss-anon-B/op │ rss-anon-B/op  vs base                │ rss-anon-B/op  vs base                │ rss-anon-B/op  vs base                │
GoferFootprint/cpus=192    7.742Mi ± 1%    6.021Mi ± 1%  -22.23% (p=0.000 n=20)    6.131Mi ± 1%  -20.81% (p=0.000 n=20)    2.104Mi ± 6%  -72.83% (p=0.000 n=20)

                        │  baseline   │           autoresearcher            │              optimized              │              stacked               │
                        │ threads/op  │ threads/op   vs base                │ threads/op   vs base                │ threads/op  vs base                │
GoferFootprint/cpus=192   54.000 ± 0%   9.000 ± 11%  -83.33% (p=0.000 n=20)   8.000 ± 12%  -85.19% (p=0.000 n=20)   6.000 ± 0%  -88.89% (p=0.000 n=20)

              │           baseline           │                   autoresearcher                    │                      optimized                       │                       stacked                        │
              │ average_container_size.bytes │ average_container_size.bytes  vs base               │ average_container_size.bytes  vs base                │ average_container_size.bytes  vs base                │
SizeNginx-192                    53.14M ± 7%                    48.18M ± 6%  -9.34% (p=0.006 n=16)                    47.66M ± 5%  -10.31% (p=0.000 n=16)                   47.03M ± 17%  -11.49% (p=0.000 n=16)

Notes on benchmark results:

  • At RunscState/cpus=129 (immediately above the 128-CPU threshold), baseline
    still fits just beneath Go's ~3.81 MiB first-GC trigger during runsc state,
    so runtime.GOMAXPROCS(8) adds ~0.3 ms (+9-11%) of procresize stop-the-world
    overhead; by cpus=144..160 (quota=150), baseline crosses the first-GC
    cliff and bounding GOMAXPROCS + scaling GOGC saves -28% to -63% wall time
    and -55% to -81% CPU time.
  • In Docker StartupEmpty-192 / StartupNginx-192 / SizeNginx-192, sec/op
    is unchanged (~) because containerd-shim already passes GOMAXPROCS to
    runsc CLI invocations, while SizeNginx-192 container memory still drops
    -10.31% / -11.49% due to the smaller gofer footprint.
Expand for sub-threshold (22-vCPU) GKE Agent Substrate checkpoint/restore validation (all 11 workloads)

End-to-end GKE Agent Substrate glutton checkpoint/restore suite on 2 x c3-standard-22 (22 vCPUs, 88 GiB RAM, pd-balanced, 0% RPC/HTTP errors, 0 OOMs across all runs). Each cell shows Clean HEAD median [min-max] (n=4 independent clean-room runs) -> After (delta); ~ indicates After falls within unmodified HEAD's observed [min-max] range across n=4 runs, and PSI memory stall % deltas are reported in percentage points (pp). Validates the <=128-CPU fast path (22 vCPUs) stacked on gofer GOMAXPROCS bounding:

Workload (per-trial samples) app_restore p50 (ms) checkpoint p50 (ms) checkpoint p95 (ms) ResumeActor p50 (ms) Worker WS p95 Worker Mem PSI p95
1u sync (n=41-44 ckpts, 7 scrapes) 29.00 [28.95-29.52] -> 28.36 (-2.2%) 33.31 [32.88-33.90] -> 33.81 (~) 38.40 [36.90-40.78] -> 41.33 (+7.6%) 80.0 [80.0-81.0] -> 80.0 (~) 24.8 MiB [20.9-30.2 MiB] -> 22.0 MiB (~) 0.00% [0.00-0.00%] -> 0.00% (~)
1u pause (n=52 ckpts, 7 scrapes) 29.27 [29.05-29.37] -> 28.77 (-1.7%) 33.44 [32.95-34.74] -> 33.29 (~) 38.84 [37.76-40.15] -> 39.63 (~) 80.5 [79.0-82.0] -> 80.0 (~) 21.7 MiB [21.3-22.3 MiB] -> 22.3 MiB (~) 0.00% [0.00-0.00%] -> 0.00% (~)
5u sync (n=204-217 ckpts, 7 scrapes) 29.45 [29.29-29.88] -> 29.02 (-1.4%) 33.65 [33.22-34.00] -> 33.35 (~) 40.44 [39.31-41.14] -> 39.30 (-2.8%) 79.0 [78.0-80.0] -> 78.0 (~) 35.1 MiB [29.4-45.7 MiB] -> 23.9 MiB (-11.2 MiB) 0.00% [0.00-0.00%] -> 0.00% (~)
5u pause (n=250-252 ckpts, 7 scrapes) 29.42 [28.97-29.78] -> 28.80 (-2.1%) 33.84 [33.28-34.08] -> 34.04 (~) 39.94 [39.63-40.64] -> 40.46 (~) 78.5 [77.0-80.0] -> 77.0 (~) 36.9 MiB [31.2-46.2 MiB] -> 43.9 MiB (~) 0.00% [0.00-0.00%] -> 0.00% (~)
10u sync (n=376-412 ckpts, 7 scrapes) 29.84 [29.71-30.38] -> 29.57 (-0.9%) 34.08 [33.83-34.12] -> 34.04 (~) 42.09 [40.43-42.42] -> 41.47 (~) 79.5 [79.0-81.0] -> 80.0 (~) 32.2 MiB [21.2-43.3 MiB] -> 43.6 MiB (+11.4 MiB) 0.00% [0.00-0.00%] -> 0.00% (~)
10u pause (n=478-481 ckpts, 7 scrapes) 29.25 [28.93-29.35] -> 29.06 (~) 33.67 [33.40-34.03] -> 33.79 (~) 39.67 [39.07-40.08] -> 40.04 (~) 78.5 [78.0-79.0] -> 79.0 (~) 30.3 MiB [28.2-41.9 MiB] -> 39.6 MiB (~) 0.00% [0.00-0.00%] -> 0.00% (~)
15u oversub (n=1789-1851 ckpts, 13 scrapes) 31.24 [31.05-31.78] -> 30.52 (-2.3%) 34.32 [34.15-34.52] -> 33.91 (-1.2%) 40.67 [40.25-40.88] -> 39.86 (-2.0%) 83.5 [83.0-84.0] -> 83.0 (~) 46.7 MiB [43.3-47.1 MiB] -> 45.8 MiB (~) 0.00% [0.00-0.00%] -> 0.00% (~)
1GiB sync (n=6-7 ckpts, 7 scrapes) 30.61 [28.48-30.77] -> 30.13 (~) 3486.4 [3266.6-3977.9] -> 3299.4 (~) 4957.9 [4749.5-5589.9] -> 4390.5 (-11.4%) 105.0 [100.0-110.0] -> 100.0 (~) 1.12 GiB [1.06-1.44 GiB] -> 1.29 GiB (~) 1.17% [0.70-1.77%] -> 1.89% (+0.71 pp)
1GiB pause (n=7-8 ckpts, 7-13 scrapes) 32.22 [30.97-37.16] -> 32.12 (~) 3917.3 [3244.3-4572.4] -> 4502.7 (~) 5235.5 [4086.0-6378.8] -> 5689.4 (~) 155.0 [100.0-270.0] -> 260.0 (~) 1.28 GiB [1.04-1.29 GiB] -> 1.16 GiB (~) 1.43% [1.33-1.89%] -> 1.88% (~)
2GiB sync (n=3 ckpts, 7 scrapes) 29.73 [29.42-30.13] -> 28.16 (-5.3%) 8967.6 [8790.8-9274.4] -> 9549.1 (+6.5%) 9991.1 [9246.3-10440.0] -> 10193.8 (~) 110.0 [100.0-110.0] -> 90.0 (-18.2%) 2.12 GiB [1.35-2.30 GiB] -> 2.30 GiB (~) 2.02% [1.63-3.15%] -> 2.18% (~)
2GiB pause (n=3-4 ckpts, 9-13 scrapes) 31.54 [31.06-32.28] -> 32.11 (~) 9677.6 [8719.4-10786.0] -> 10099.5 (~) 10004.0 [8770.5-16934.0] -> 10431.3 (~) 205.0 [100.0-290.0] -> 89.0 (-56.6%) 2.19 GiB [1.47-2.47 GiB] -> 2.29 GiB (~) 3.23% [2.03-3.38%] -> 2.06% (~)

Tradeoffs & variance notes:

  • Zero sub-threshold CLI fast-path regressions: on 22-vCPU nodes (<=128 threshold), maxprocs.init() returns immediately with 0 allocations; app_restore p50 is faster than HEAD's 4-run [min-max] band on 7/11 workloads (-0.9% to -5.3%) and ~ on the remaining 4/11.
  • Large-memory single-trial variance (n=3-7 ckpts, 7 scrapes): 2GiB sync checkpoint p50 (9549.1 ms vs 8967.6 [8790.8-9274.4] ms, +6.5%, n=3 ckpts; p95 10193.8 ms ~) and 1GiB sync worker memory PSI p95 (1.89% vs 1.17% [0.70-1.77%], +0.71 pp vs median / +0.12 pp above HEAD max, n=7 scrapes) reflect single-trial pd-balanced flush timing rather than runsc CLI startup.
  • Lightweight scrape alignment: 10u sync worker working set (43.6 MiB vs 32.2 [21.2-43.3] MiB, n=7 scrapes) is 0.3 MiB above HEAD max (5u sync dropped -11.2 MiB to 23.9 MiB for the same 10s scrape phase reason).

Fixes #16140

… hosts.

The Go runtime automatically makes processor structs up to the number
of cores that are visible (around 16 kibs per processor struct).
Notably, Go's first gc collection cycle defaults to ~3.81 mibs, so
on machines with >128 cpus, the structs get us close to that limit,
and init()s can get us past that limit before the main function of a
command starts.

The effects are felt most on very short lived commands, where the time
spent in the GC cycle is greater than the time spent exec'ing the command.

So:
- Lower GOMAXPROCS to 8 at the start of package init
- Scale initial GOGC (when bootstrap GC hasn't already run) to offset retained
  runtime.p spans
- Restore the pre-init GOGC in long-lived allocating subcommands (gofer,
  non-stream port-forward, and streaming events)

Isolated GCE `c4-standard-192` COS benchmarks (192 vCPUs, `n=20` interleaved):

<details>

<summary>Expand for full GCE c4-standard-192 COS benchstat output</summary>

Arms (`n=20` interleaved; `n=16` for Docker `Startup*`/`Size*`):
- `baseline`: clean `main`
- `autoresearcher`: early `GOMAXPROCS=8` above 128 CPUs without initial `GOGC` scaling
- `optimized`: this change standalone
- `stacked`: this change stacked on gofer `GOMAXPROCS` bounding

```
goos: linux
goarch: amd64
pkg: gvisor.dev/gvisor/runsc/cli/maxprocs
                            │   baseline    │            autoresearcher            │              optimized              │               stacked               │
                            │    sec/op     │    sec/op     vs base                │   sec/op     vs base                │   sec/op     vs base                │
RunscState/cpus=2              2.776m ±  1%    2.748m ± 3%        ~ (p=0.799 n=20)   2.729m ± 2%        ~ (p=0.242 n=20)   2.788m ± 2%        ~ (p=0.383 n=20)
RunscState/cpus=4              2.895m ±  2%    2.831m ± 4%        ~ (p=0.341 n=20)   2.831m ± 2%        ~ (p=0.114 n=20)   2.922m ± 2%        ~ (p=0.289 n=20)
RunscState/cpus=16             2.713m ±  1%    2.702m ± 3%        ~ (p=0.461 n=20)   2.724m ± 2%        ~ (p=0.841 n=20)   2.744m ± 2%        ~ (p=0.201 n=20)
RunscState/cpus=48             2.816m ±  4%    2.772m ± 4%        ~ (p=0.678 n=20)   2.737m ± 3%        ~ (p=0.157 n=20)   2.842m ± 4%        ~ (p=0.341 n=20)
RunscState/cpus=96             3.265m ±  3%    3.215m ± 3%        ~ (p=0.602 n=20)   3.143m ± 4%        ~ (p=0.086 n=20)   3.269m ± 4%        ~ (p=0.114 n=20)
RunscState/cpus=128            3.268m ±  3%    3.287m ± 5%        ~ (p=0.429 n=20)   3.225m ± 5%        ~ (p=0.925 n=20)   3.241m ± 3%        ~ (p=0.947 n=20)
RunscState/cpus=129            3.197m ±  8%    3.484m ± 2%   +8.95% (p=0.000 n=20)   3.490m ± 4%   +9.15% (p=0.000 n=20)   3.536m ± 4%  +10.60% (p=0.000 n=20)
RunscState/cpus=144            3.770m ± 12%    3.768m ± 6%        ~ (p=0.799 n=20)   3.673m ± 4%        ~ (p=0.904 n=20)   3.725m ± 2%        ~ (p=0.799 n=20)
RunscState/cpus=160            7.545m ±  5%    4.368m ± 3%  -42.11% (p=0.000 n=20)   3.835m ± 6%  -49.18% (p=0.000 n=20)   3.940m ± 4%  -47.79% (p=0.000 n=20)
RunscState/cpus=192           11.514m ±  3%    6.156m ± 4%  -46.53% (p=0.000 n=20)   4.259m ± 1%  -63.01% (p=0.000 n=20)   4.253m ± 3%  -63.06% (p=0.000 n=20)
RunscState/quota=150           6.079m ± 13%    4.433m ± 4%  -27.07% (p=0.000 n=20)   4.352m ± 2%  -28.40% (p=0.000 n=20)   4.392m ± 2%  -27.75% (p=0.000 n=20)
ContainerLifecycle/cpus=16     60.83m ±  1%    60.46m ± 1%        ~ (p=0.461 n=20)   60.34m ± 1%        ~ (p=0.211 n=20)   60.92m ± 1%        ~ (p=0.355 n=20)
ContainerLifecycle/cpus=96     82.32m ±  5%    82.08m ± 3%        ~ (p=0.779 n=20)   81.10m ± 4%        ~ (p=0.096 n=20)   83.78m ± 3%        ~ (p=0.242 n=20)
ContainerLifecycle/cpus=128    74.94m ±  3%    75.03m ± 2%        ~ (p=1.000 n=20)   75.25m ± 5%        ~ (p=0.341 n=20)   76.27m ± 5%        ~ (p=0.947 n=20)
ContainerLifecycle/cpus=160   108.36m ±  3%    84.59m ± 3%  -21.93% (p=0.000 n=20)   76.73m ± 2%  -29.19% (p=0.000 n=20)   78.14m ± 3%  -27.90% (p=0.000 n=20)
ContainerLifecycle/cpus=192   155.25m ±  3%   102.14m ± 4%  -34.21% (p=0.000 n=20)   92.11m ± 2%  -40.67% (p=0.000 n=20)   93.67m ± 4%  -39.67% (p=0.000 n=20)
StartupEmpty-192               373.7m ±  5%    367.6m ± 5%        ~ (p=0.515 n=16)   369.7m ± 4%        ~ (p=0.616 n=16)   368.9m ± 7%        ~ (p=0.361 n=16)
StartupNginx-192               654.0m ±  3%    667.9m ± 5%        ~ (p=0.867 n=16)   651.2m ± 3%        ~ (p=0.669 n=16)   659.4m ± 3%        ~ (p=0.956 n=16)
SizeNginx-192                  873.4m ±  3%    861.9m ± 2%        ~ (p=0.752 n=16)   866.7m ± 3%        ~ (p=0.867 n=16)   866.7m ± 5%        ~ (p=0.838 n=16)
geomean                        20.07m          17.93m       -10.69%                  17.17m       -14.46%                  17.45m       -13.07%

                     │   baseline   │           autoresearcher           │             optimized              │              stacked               │
                     │  cpu-ms/op   │ cpu-ms/op   vs base                │ cpu-ms/op   vs base                │ cpu-ms/op   vs base                │
RunscState/cpus=2       2.636 ±  2%   2.628 ± 3%        ~ (p=0.857 n=20)   2.617 ± 2%        ~ (p=0.703 n=20)   2.664 ± 1%        ~ (p=0.433 n=20)
RunscState/cpus=4       2.982 ±  2%   2.938 ± 4%        ~ (p=0.344 n=20)   2.927 ± 2%   -1.83% (p=0.042 n=20)   2.987 ± 2%        ~ (p=0.836 n=20)
RunscState/cpus=16      2.873 ±  1%   2.880 ± 1%        ~ (p=0.683 n=20)   2.883 ± 2%        ~ (p=0.683 n=20)   2.912 ± 2%        ~ (p=0.176 n=20)
RunscState/cpus=48      3.050 ±  4%   2.999 ± 5%        ~ (p=0.888 n=20)   2.954 ± 3%        ~ (p=0.304 n=20)   3.085 ± 4%        ~ (p=0.425 n=20)
RunscState/cpus=96      3.567 ±  3%   3.515 ± 2%        ~ (p=0.703 n=20)   3.450 ± 2%        ~ (p=0.116 n=20)   3.569 ± 3%        ~ (p=0.142 n=20)
RunscState/cpus=128     3.508 ±  3%   3.534 ± 4%        ~ (p=0.774 n=20)   3.492 ± 3%        ~ (p=0.941 n=20)   3.500 ± 2%        ~ (p=0.836 n=20)
RunscState/cpus=129     3.489 ±  6%   3.734 ± 3%   +7.02% (p=0.002 n=20)   3.755 ± 4%   +7.63% (p=0.001 n=20)   3.814 ± 4%   +9.33% (p=0.000 n=20)
RunscState/cpus=144     4.752 ± 24%   4.046 ± 4%        ~ (p=0.529 n=20)   3.962 ± 3%        ~ (p=0.465 n=20)   3.997 ± 3%        ~ (p=0.529 n=20)
RunscState/cpus=160    14.334 ±  6%   5.103 ± 4%  -64.40% (p=0.000 n=20)   4.139 ± 4%  -71.12% (p=0.000 n=20)   4.197 ± 4%  -70.72% (p=0.000 n=20)
RunscState/cpus=192    23.596 ±  4%   7.796 ± 2%  -66.96% (p=0.000 n=20)   4.574 ± 4%  -80.62% (p=0.000 n=20)   4.488 ± 4%  -80.98% (p=0.000 n=20)
RunscState/quota=150   10.531 ±  9%   4.814 ± 4%  -54.28% (p=0.000 n=20)   4.654 ± 2%  -55.81% (p=0.000 n=20)   4.697 ± 2%  -55.40% (p=0.000 n=20)
geomean                 5.019         3.802       -24.25%                  3.521       -29.85%                  3.571       -28.85%

                            │   baseline    │            autoresearcher             │               optimized               │                stacked                │
                            │ cli-cpu-ms/op │ cli-cpu-ms/op  vs base                │ cli-cpu-ms/op  vs base                │ cli-cpu-ms/op  vs base                │
ContainerLifecycle/cpus=16       37.33 ± 1%     37.37 ±  1%        ~ (p=0.952 n=20)      36.80 ± 2%        ~ (p=0.183 n=20)      37.68 ± 1%        ~ (p=0.149 n=20)
ContainerLifecycle/cpus=96       51.17 ± 4%     49.33 ±  7%        ~ (p=0.445 n=20)      48.77 ± 3%   -4.70% (p=0.012 n=20)      50.56 ± 4%        ~ (p=0.820 n=20)
ContainerLifecycle/cpus=128      66.74 ± 9%     69.65 ± 10%        ~ (p=0.758 n=20)      67.19 ± 7%        ~ (p=0.583 n=20)      68.83 ± 8%        ~ (p=1.000 n=20)
ContainerLifecycle/cpus=160     151.24 ± 4%     71.96 ±  2%  -52.42% (p=0.000 n=20)      52.62 ± 2%  -65.21% (p=0.000 n=20)      53.20 ± 4%  -64.83% (p=0.000 n=20)
ContainerLifecycle/cpus=192     248.93 ± 5%     85.47 ±  5%  -65.67% (p=0.000 n=20)      61.20 ± 5%  -75.41% (p=0.000 n=20)      62.54 ± 2%  -74.88% (p=0.000 n=20)
geomean                          86.35          60.19        -30.30%                     52.22       -39.52%                     53.45       -38.10%

                        │   baseline   │            autoresearcher            │              optimized              │               stacked                │
                        │   pss-B/op   │   pss-B/op    vs base                │   pss-B/op    vs base               │   pss-B/op    vs base                │
GoferFootprint/cpus=192   17.81Mi ± 0%   15.94Mi ± 1%  -10.48% (p=0.000 n=20)   16.10Mi ± 1%  -9.61% (p=0.000 n=20)   11.87Mi ± 1%  -33.34% (p=0.000 n=20)

                        │   baseline    │            autoresearcher             │               optimized               │                stacked                │
                        │ rss-anon-B/op │ rss-anon-B/op  vs base                │ rss-anon-B/op  vs base                │ rss-anon-B/op  vs base                │
GoferFootprint/cpus=192    7.742Mi ± 1%    6.021Mi ± 1%  -22.23% (p=0.000 n=20)    6.131Mi ± 1%  -20.81% (p=0.000 n=20)    2.104Mi ± 6%  -72.83% (p=0.000 n=20)

                        │  baseline   │           autoresearcher            │              optimized              │              stacked               │
                        │ threads/op  │ threads/op   vs base                │ threads/op   vs base                │ threads/op  vs base                │
GoferFootprint/cpus=192   54.000 ± 0%   9.000 ± 11%  -83.33% (p=0.000 n=20)   8.000 ± 12%  -85.19% (p=0.000 n=20)   6.000 ± 0%  -88.89% (p=0.000 n=20)

              │           baseline           │                   autoresearcher                    │                      optimized                       │                       stacked                        │
              │ average_container_size.bytes │ average_container_size.bytes  vs base               │ average_container_size.bytes  vs base                │ average_container_size.bytes  vs base                │
SizeNginx-192                    53.14M ± 7%                    48.18M ± 6%  -9.34% (p=0.006 n=16)                    47.66M ± 5%  -10.31% (p=0.000 n=16)                   47.03M ± 17%  -11.49% (p=0.000 n=16)
```

Notes on benchmark results:
- At `RunscState/cpus=129` (immediately above the 128-CPU threshold), `baseline`
  still fits just beneath Go's ~3.81 MiB first-GC trigger during `runsc state`,
  so `runtime.GOMAXPROCS(8)` adds ~0.3 ms (+9-11%) of `procresize` stop-the-world
  overhead; by `cpus=144..160` (`quota=150`), `baseline` crosses the first-GC
  cliff and bounding `GOMAXPROCS` + scaling `GOGC` saves -28% to -63% wall time
  and -55% to -81% CPU time.
- In Docker `StartupEmpty-192` / `StartupNginx-192` / `SizeNginx-192`, `sec/op`
  is unchanged (`~`) because `containerd-shim` already passes `GOMAXPROCS` to
  `runsc` CLI invocations, while `SizeNginx-192` container memory still drops
  -10.31% / -11.49% due to the smaller gofer footprint.

</details>

<details>

<summary>Expand for sub-threshold (22-vCPU) GKE Agent Substrate checkpoint/restore validation (all 11 workloads)</summary>

End-to-end GKE Agent Substrate `glutton` checkpoint/restore suite on `2 x c3-standard-22` (22 vCPUs, 88 GiB RAM, `pd-balanced`, `0%` RPC/HTTP errors, `0` OOMs across all runs). Each cell shows `Clean HEAD median [min-max] (n=4 independent clean-room runs) -> After (delta)`; `~` indicates `After` falls within unmodified `HEAD`'s observed `[min-max]` range across `n=4` runs, and PSI memory stall `%` deltas are reported in percentage points (`pp`). Validates the `<=128`-CPU fast path (`22` vCPUs) stacked on gofer `GOMAXPROCS` bounding:

| Workload (per-trial samples) | `app_restore` p50 (ms) | `checkpoint` p50 (ms) | `checkpoint` p95 (ms) | `ResumeActor` p50 (ms) | Worker WS p95 | Worker Mem PSI p95 |
| :--- | ---: | ---: | ---: | ---: | ---: | ---: |
| `1u sync` (n=41-44 ckpts, 7 scrapes) | 29.00 [28.95-29.52] -> 28.36 (-2.2%) | 33.31 [32.88-33.90] -> 33.81 (~) | 38.40 [36.90-40.78] -> 41.33 (+7.6%) | 80.0 [80.0-81.0] -> 80.0 (~) | 24.8 MiB [20.9-30.2 MiB] -> 22.0 MiB (~) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `1u pause` (n=52 ckpts, 7 scrapes) | 29.27 [29.05-29.37] -> 28.77 (-1.7%) | 33.44 [32.95-34.74] -> 33.29 (~) | 38.84 [37.76-40.15] -> 39.63 (~) | 80.5 [79.0-82.0] -> 80.0 (~) | 21.7 MiB [21.3-22.3 MiB] -> 22.3 MiB (~) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `5u sync` (n=204-217 ckpts, 7 scrapes) | 29.45 [29.29-29.88] -> 29.02 (-1.4%) | 33.65 [33.22-34.00] -> 33.35 (~) | 40.44 [39.31-41.14] -> 39.30 (-2.8%) | 79.0 [78.0-80.0] -> 78.0 (~) | 35.1 MiB [29.4-45.7 MiB] -> 23.9 MiB (-11.2 MiB) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `5u pause` (n=250-252 ckpts, 7 scrapes) | 29.42 [28.97-29.78] -> 28.80 (-2.1%) | 33.84 [33.28-34.08] -> 34.04 (~) | 39.94 [39.63-40.64] -> 40.46 (~) | 78.5 [77.0-80.0] -> 77.0 (~) | 36.9 MiB [31.2-46.2 MiB] -> 43.9 MiB (~) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `10u sync` (n=376-412 ckpts, 7 scrapes) | 29.84 [29.71-30.38] -> 29.57 (-0.9%) | 34.08 [33.83-34.12] -> 34.04 (~) | 42.09 [40.43-42.42] -> 41.47 (~) | 79.5 [79.0-81.0] -> 80.0 (~) | 32.2 MiB [21.2-43.3 MiB] -> 43.6 MiB (+11.4 MiB) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `10u pause` (n=478-481 ckpts, 7 scrapes) | 29.25 [28.93-29.35] -> 29.06 (~) | 33.67 [33.40-34.03] -> 33.79 (~) | 39.67 [39.07-40.08] -> 40.04 (~) | 78.5 [78.0-79.0] -> 79.0 (~) | 30.3 MiB [28.2-41.9 MiB] -> 39.6 MiB (~) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `15u oversub` (n=1789-1851 ckpts, 13 scrapes) | 31.24 [31.05-31.78] -> 30.52 (-2.3%) | 34.32 [34.15-34.52] -> 33.91 (-1.2%) | 40.67 [40.25-40.88] -> 39.86 (-2.0%) | 83.5 [83.0-84.0] -> 83.0 (~) | 46.7 MiB [43.3-47.1 MiB] -> 45.8 MiB (~) | 0.00% [0.00-0.00%] -> 0.00% (~) |
| `1GiB sync` (n=6-7 ckpts, 7 scrapes) | 30.61 [28.48-30.77] -> 30.13 (~) | 3486.4 [3266.6-3977.9] -> 3299.4 (~) | 4957.9 [4749.5-5589.9] -> 4390.5 (-11.4%) | 105.0 [100.0-110.0] -> 100.0 (~) | 1.12 GiB [1.06-1.44 GiB] -> 1.29 GiB (~) | 1.17% [0.70-1.77%] -> 1.89% (+0.71 pp) |
| `1GiB pause` (n=7-8 ckpts, 7-13 scrapes) | 32.22 [30.97-37.16] -> 32.12 (~) | 3917.3 [3244.3-4572.4] -> 4502.7 (~) | 5235.5 [4086.0-6378.8] -> 5689.4 (~) | 155.0 [100.0-270.0] -> 260.0 (~) | 1.28 GiB [1.04-1.29 GiB] -> 1.16 GiB (~) | 1.43% [1.33-1.89%] -> 1.88% (~) |
| `2GiB sync` (n=3 ckpts, 7 scrapes) | 29.73 [29.42-30.13] -> 28.16 (-5.3%) | 8967.6 [8790.8-9274.4] -> 9549.1 (+6.5%) | 9991.1 [9246.3-10440.0] -> 10193.8 (~) | 110.0 [100.0-110.0] -> 90.0 (-18.2%) | 2.12 GiB [1.35-2.30 GiB] -> 2.30 GiB (~) | 2.02% [1.63-3.15%] -> 2.18% (~) |
| `2GiB pause` (n=3-4 ckpts, 9-13 scrapes) | 31.54 [31.06-32.28] -> 32.11 (~) | 9677.6 [8719.4-10786.0] -> 10099.5 (~) | 10004.0 [8770.5-16934.0] -> 10431.3 (~) | 205.0 [100.0-290.0] -> 89.0 (-56.6%) | 2.19 GiB [1.47-2.47 GiB] -> 2.29 GiB (~) | 3.23% [2.03-3.38%] -> 2.06% (~) |

Tradeoffs & variance notes:
- Zero sub-threshold CLI fast-path regressions: on 22-vCPU nodes (`<=128` threshold), `maxprocs.init()` returns immediately with 0 allocations; `app_restore` p50 is faster than `HEAD`'s 4-run `[min-max]` band on 7/11 workloads (`-0.9%` to `-5.3%`) and `~` on the remaining 4/11.
- Large-memory single-trial variance (`n=3-7` ckpts, `7` scrapes): `2GiB sync` `checkpoint` p50 (`9549.1 ms` vs `8967.6 [8790.8-9274.4] ms`, `+6.5%`, `n=3` ckpts; p95 `10193.8 ms` `~`) and `1GiB sync` worker memory PSI p95 (`1.89%` vs `1.17% [0.70-1.77%]`, `+0.71 pp` vs median / `+0.12 pp` above `HEAD` max, `n=7` scrapes) reflect single-trial `pd-balanced` flush timing rather than `runsc` CLI startup.
- Lightweight scrape alignment: `10u sync` worker working set (`43.6 MiB` vs `32.2 [21.2-43.3] MiB`, `n=7` scrapes) is `0.3 MiB` above `HEAD` max (`5u sync` dropped `-11.2 MiB` to `23.9 MiB` for the same 10s scrape phase reason).

</details>

Fixes #16140

PiperOrigin-RevId: 1010065697
@copybara-service copybara-service Bot added the exported Issue was exported automatically label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimization: Bound runsc's GOMAXPROCS during init on hosts with more than 128 CPUs

1 participant