Skip to content

session: DefaultConcurrency=4 is the per-process throughput cap — raising it beats adding workers (2.74x) #305

Closed

Description

@pdettori

The per-process throughput cap found by #259 is session.DefaultConcurrency = 4. Raising it
on a single worker gave 2.74x, which is 1.40x better than #259's entire two-worker
result
— so "scale out" is the wrong first move.

Measured on srv-r16b14s16 (bare metal, SH_SUBSTRATE=metal, SH_E11_EXEC_CLIENT=go,
2026-09-21).

The code

remote-worker/internal/session/loop.go starts a fixed pool of goroutines, one per
concurrency slot, draining the Exec queue:

for i := 0; i < s.cfg.MaxConcurrent; i++ {
    wg.Add(1)
    go func() {
        defer wg.Done()
        for e := range c.queue { ... s.runOne(sl.ctx, enqueue, e) ... }
    }()
}
// DefaultConcurrency is the pool size, advertised as Hello.capacity_max.
DefaultConcurrency = 4

microvm-worker takes it from WORKER_MAX_CONCURRENT, defaulting to DefaultConcurrency
(cmd/microvm-worker/main.go:443). e11-density.sh's start_microvm_stack never sets it.
So every E11 microVM rung ever recorded was limited to 4 concurrent Execs per worker,
whatever c the driver drove.

It predicts every number we already had

That is what makes it the root cause rather than another candidate. Pool-level per-Exec cost
is ~62 ms (measured, see #307):

operating point predicted = slots / per-Exec latency measured
c=1 1 / 55 ms = 18.2 18.18
c=8 4 / 62.2 ms = 64.3 67.76
c=16 4 / 61.4 ms = 65.1 62.99
two workers (#259) 8 slots -> 2x 1.82-1.92x

It also explains the two things that made this puzzling: the host stayed ~93% idle because only
4 Execs were ever in flight, and the c>=8 "knee" (#291) is simply c passing the slot count.

An under-load SIGQUIT goroutine dump showed exactly 4 goroutines in
session.(*Session).Serve.func5 — the cap was directly observable.

The confirming test

One worker, c=16, changing only WORKER_MAX_CONCURRENT:

config throughput p95 host cores of 72 coresBusy/Exec-s
1 worker, MaxConcurrent=4 (default) 62.99 154.3 ms 4.00 0.063
1 worker, MaxConcurrent=16 172.88 159.8 ms 12.98 0.075
2 workers, MaxConcurrent=4 each (#259) 123.57 154.5 ms 7.57 0.061

2.74x for +3.6% p95, on one process, with the host still 82% idle
(hostCpuSamples 148, so the CPU figure is quotable).

What this means for #259 and #291

Open questions, deliberately not answered here

  • Where should the default sit? 4 is defensible for a small container worker and clearly
    wrong for a 72-core microVM host. It is advertised as Hello.capacity_max, so raising it
    changes what the relay is told it may dispatch — that is a design decision, not a tuning one.
  • What binds next? At MaxConcurrent=16 the host is 18% busy, so there is headroom for
    roughly another 4-5x. Per-Exec latency grew 61.4 -> 88.7 ms at 4x the slots, and destroy
    grew 33.7 -> 46.8 ms, so the next limit is probably in teardown (vmpool: Destroy is still ~55% of every Exec, and 89% of it is cmd.Wait (SIGKILL to reap) #307).
  • Memory scales with the cap (internal/exec/runner.go:41: 2 streams x MaxConcurrent x
    BufferCap), so raising it is not free.

Refs #259, #291, #303

Activity

  1. pdettori commented on Sep 21, 2026

    @pdettori
    MemberAuthor

    Correction to this issue's own evidence. The headline measurement stands — one worker went from
    62.99 to 172.88 Exec/s on WORKER_MAX_CONCURRENT alone, and that is a direct experiment. But
    the claim above that the 4-slot cap "predicts every number we already had" is too strong, and
    one published point contradicts it.

    The point that does not fit

    Checking the cap against #291's full microVM ladder (PR #300), at ~60.8 ms per Exec a 4-slot
    server has a capacity of ~65.8 Exec/s:

    c tput/s implied effective slots
    1 17.56 1.07
    2 34.38 2.09
    4 65.79 4.00 — exactly the cap
    8 80.62 4.90 — above the cap
    16 62.99 3.83
    32 62.61 3.81
    64 62.28 3.79

    c=4 lands on 4.00 slots, and the c>=16 plateau is a clean fixed-capacity signature — flat
    throughput with p95 doubling per doubling of c (117.79 -> 268.51 -> 522.91 -> 1033.82 ms), which
    is queueing against a fixed number of servers. Both support the cap.

    c=8 at 80.62 does not. A 4-slot pool cannot exceed 4 concurrent Execs, and 80.62 implies
    ~4.9. The same shape appears on the container arm: exactly 4 slots' worth at c=4 (1541.81 against
    a 1544 prediction) and ~5.0 slots from c=8 onward. So it is systematic, not noise in one rung.

    What that changes, and what it does not

    • Unchanged: slots were the binding constraint, and raising them is the cheapest large win
      available. 62.99 -> 172.88 is a measurement, not an inference.
    • Unchanged: the c>=16 plateau is the cap.
    • Weakened: "the knee is at c=8 because of the cap". The plateau the knee falls to is the
      cap; the peak's position is not accounted for.
    • Withdrawn: "predicts every number we already had". It predicts c=1, c=2, c=4, the
      c>=16 plateau, and the two-worker result. It does not predict c=8.

    What would settle it

    Candidates in order of cheapness — tracked as Discrepancy B in the plan:

    1. Window effects. throughput is all_ok / wall_s; if the timed window includes ramp-up the
      mean is not the steady-state rate. Check whether WARMUP_PER_SLOT (default 3) covers it.
    2. A path that bypasses the worker pool. The heartbeat goroutine and the recv loop are separate
      from the MaxConcurrent workers; worth reading accept/runOne for anything that can complete
      an Exec outside the pool.
    3. Count concurrency directly rather than inferring it: re-run the full ladder at
      MaxConcurrent=4 with SH_DIAG_PHASES=1 (feat(vmpool): surface Exec/restore phases and add opt-in pprof #308) and count in-flight Execs from the phase-log
      timestamps.

    If c=8 genuinely exceeds 4 slots then the cap is a soft one and this issue's arithmetic needs
    restating — the 2.74x stands either way, but the mechanism would not be fully described.

    Refs #300, rossoctl/moca-experiments#8, #308

  2. pdettori commented on Sep 21, 2026

    @pdettori
    MemberAuthor

    Task 1.2 — the default decision, and the reasoning behind it

    Per the plan's instruction to record the reasoning here, since this is the number that set
    every throughput figure the project has published.

    Decision: a per-tier default. microvmDefaultConcurrency = 16 for the microVM worker
    (PR #313); session.DefaultConcurrency stays 4 for the container worker.

    Why not one raised constant

    The per-slot cost that makes slots expensive is 2 × exec.BufferCap (8 MiB) of stream buffer,
    and it is the container worker that pays it against a hard pod limit:

    slots worst-case buffers vs worker-deployment.yaml's 256Mi
    4 64 MiB ~4× headroom for the transient bytes.Buffer doubling
    16 256 MiB at the limit — no headroom

    That manifest's own comment records fixing this exact thing: "A 64Mi limit was therefore an
    OOMKill the relay could trigger at will." And runner.go notes Exec.streaming is
    relay-supplied with false as the proto3 default, so the worst case is reachable with no
    privilege
    . Raising the shared constant would reinstate an already-fixed vector in a tier that
    gains nothing from the slots.

    The microVM worker has no pod limit — it runs as a process, with no manifest in the tree — and
    its memory is gated by the mandatory SH_MAX_COMMITTED_MB over 256 MiB guests, beside which
    256 MiB of buffers is negligible. The two tiers have genuinely different memory models, so one
    constant could only ever be right for one of them.

    Why 16 and not higher

    16 is the largest slot count actually measured (172.88 Exec/s vs 62.99 at 4, same host).
    Everything above it is extrapolation from one point. A test pins the constant to 16 with that
    reasoning in its failure message, so raising it must be deliberate and carry its own
    measurement — which is Task 1.3.

    The premise this task was filed under does not hold

    The plan flagged Task 1.2 as a contract change because the default is "advertised as
    Hello.capacity_max, so raising it changes what the relay is told it may dispatch."

    Nothing reads capacity_max. packages/sandbox-relay/src/relay.ts says so directly —
    "Advertised by the worker but not yet consulted for leasing — select-sandbox still leases
    against its own opts.cap. Wiring capacityMax into leasing decisions is a later slice." The
    harness leases against KAGENTI_SANDBOX_CAP, default 20 (harness/src/lease-timings.ts),
    enforced as concurrent lease holders per sandbox via a Redis sorted set.

    So the effective production configuration already permits 20 concurrent holders per sandbox
    against a worker that serves 4 concurrent Execs — a 5x over-dispatch that has always been
    there. Raising the worker's slot count moves those two numbers toward each other rather than
    breaking a contract anything consults.

    Worth noting as a separate item: the fact that these two numbers were never reconciled, and
    that the field which would reconcile them is advertised and ignored, is its own latent defect.
    It is not on the throughput path, so I have not filed it here.

    Also fixed, since it is the same defect class as this issue

    The inline resolution discarded its error:

    if v, e := envInt64(get, "WORKER_MAX_CONCURRENT", ...); e == nil { maxConcurrent = int(v) }

    WORKER_MAX_CONCURRENT=abc therefore ran silently at the default slot count. A run whose slots
    came from a typo must not be indistinguishable from a run that chose them — that is precisely
    how this issue's 4-slot cap went unnoticed across every published microVM ladder. Now fatal.

    Task 1.1 (PR #312), for cross-reference

    e11-density.sh now sets WORKER_MAX_CONCURRENT explicitly, defaulting to the ladder's largest
    c, refusing a malformed override, and warning when slots sit below the largest rung. Step 4
    of that task needed no work: #311 had already added maxConcurrent to the rung record, read
    back from the worker's own /stats — strictly better than recording what the driver believes it
    set.

  3. added 2 commits that reference this issue on Sep 21, 2026
  4. pdettori commented on Sep 21, 2026

    @pdettori
    MemberAuthor

    Task 1.3 — the slot sweep: the knee is 16, and CPU is not what stops it

    Measured on srv-r16b14s16 (72 cpu, 754 GiB, virt=none, governor performance, swap off),
    2026-09-21, microVM arm, SH_E11_EXEC_CLIENT=go, D=2, 256 MiB guests, SH_E11_ITERS_PER_SLOT=400,
    SH_DIAG_PHASES=1, main at e170ae0 (so it includes #309/#312).

    Five separate runs, one per point, each with slots == c. A single ladder cannot do this:
    start_microvm_stack is called once per (D, guest-RAM) slice with the ladder's largest c, so
    SH_E11_ACTIVE_RUNS="4 8 16 32 64" would have run every rung at 64 slots.

    Foreign load over the whole window: mean 0.52%, and the one 50% spike is our own scratch redis
    container (it runs as polkitd, and foreign-load.sh counts anything not root/dettori as
    foreign). galmasi was logged in but idle. hostCpuSamples was 25-381 per rung, so every CPU
    figure below clears the >= 10 bar.

    Throughput peaks at 16 slots and then regresses

    slots (= c) Exec/s x vs 4 x per doubling p95 ms coresBusy / 72 host CPU cold rate (true) Exec errors
    4 60.80 1.00x — 90.9 3.90 5.4% 0.192 none
    8 107.03 1.76x 1.76x 100.9 7.10 9.9% 0.207 none
    16 170.92 2.81x 1.60x 165.7 13.02 18.1% 0.283 none
    32 120.49 1.98x 0.70x 730.3 12.90 17.9% 0.630 none
    64 59.69 0.98x 0.50x 3041.4 12.16 16.9% 0.760 spawn-failure=23

    The knee is 16 slots, at 18.1% host CPU. 170.92 Exec/s reproduces the 172.88 measured
    independently before this sweep to within 1.1%. Past 16 it does not plateau — it collapses:
    at 64 slots throughput is back to the 4-slot figure and p95 is 33x worse.

    This refutes the ~800 Exec/s extrapolation. That figure assumed slots keep paying until CPU
    binds at ~85%. The host never exceeded 18.1%, and coresBusy actually falls above the knee
    (13.02 -> 12.90 -> 12.16) while throughput halves. Whatever binds here, it is not CPU.

    What binds: the standby replenishment rate

    Per-Exec phases, from the worker's own SH_DIAG_PHASES lines:

    slots Execs Acquire ms Resume ms Run ms Destroy ms total ms
    4 1,616 4.18 23.32 4.00 32.28 63.78
    8 3,232 4.79 23.64 4.08 39.59 72.10
    16 6,464 14.29 24.25 4.23 46.98 89.75
    32 12,928 172.81 24.88 4.37 54.73 256.78
    64 25,856 940.18 25.76 4.52 62.93 1033.38

    Resume is flat (23.3 -> 25.8) and Run is flat (4.0 -> 4.5). Destroy grows moderately
    (32 -> 63). Acquire grows 225x. An acquire only costs anything when no warm standby is
    available, and the cold causes say exactly that — overwhelmingly exhausted (replenishment
    behind the Exec rate), never meaningfully first-exec:

    • slots=4: exhausted=310, first-exec=4
    • slots=16: exhausted=1,827, first-exec=16
    • slots=64: exhausted=19,577, first-exec=64 (of 25,856 Execs)

    So the ceiling is the rate at which the pool can produce a fresh warm standby. Slots beyond
    that rate add queueing, not throughput.

    Inside a restore, it is one line of code

    Restore sub-phases (also from the worker's own log):

    slots restores prep wsimg jailer sockwait loadsnap total sockwait share restore TIMEOUTS
    4 1,625 0.22 0.05 0.39 24.92 2.14 27.73 89.9% 0
    8 3,249 0.23 0.06 0.41 24.11 2.25 27.06 89.1% 0
    16 6,497 0.25 0.10 0.48 54.23 2.45 57.52 94.3% 0
    32 12,993 0.26 0.28 0.52 331.98 2.67 335.71 98.9% 0
    64 25,962 0.24 0.30 0.50 1722.55 3.04 1726.62 99.8% 396

    Every other sub-phase is flat across a 16x range of concurrency. prep ~0.24 ms, jailer
    ~0.5 ms, loadsnap 2.1 -> 3.0 ms. Real work in a restore is 2.80 ms. sockwait —
    waitForUnixSocket — is 89.9% of a restore even on an idle box, and 99.8% at 64 slots.

    And it is quantized by the fixed 20 ms poll, exactly as #304 describes:

    slots=4   n=1625   min=20.06ms  p50=20.57ms  max=42.19ms
              strictly below one 20ms quantum: 0 (0.00%)
              [20-40ms)=1270 (78.2%)   [40-60ms)=355 (21.8%)
    

    Zero restores completed in under 20 ms, on 1,625 samples, over ~2.8 ms of real work. The
    78/22 split across the first two quanta reproduces the earlier distribution exactly.

    At 64 slots it is no longer quantized (p50 1540 ms, max 5019 ms), so up there the socket is
    genuinely slow and 396 restores hit waitForUnixSocket's 5 s ceiling and failed —
    replenish ...: restore vm-N: API socket never appeared: timed out after 5s. Those surfaced as
    the 23 spawn-failure Execs. Above the knee, replenishment is not merely slow; it breaks.

    What this changes in the plan

    1. vmpool: waitForUnixSocket's fixed 20ms retry is 90% of every restore (TDD) #304 should be promoted ahead of P4: decompose resume (28.58 ms) and destroy (21.31 ms) into their sub-costs #258. vmpool: waitForUnixSocket's fixed 20ms retry is 90% of every restore (TDD) #304 is currently sequenced last, on the reasoning
      that ">99% of acquires are warm, so almost nothing waits on a restore" and its throughput
      effect "at the current default is ~0". That was true at 4 slots. It is not true anywhere at or
      above the knee: at 16 slots the cold rate is 0.283 and Acquire is already 14.3 ms, and the
      replenishment rate that sets the ceiling is the restore rate — 90% of which is a sleep.
    2. P4: decompose resume (28.58 ms) and destroy (21.31 ms) into their sub-costs #258 (Destroy) is still real but is no longer the headline. At the knee Destroy is
      46.98 ms, 52.3% of an Exec, so halving it remains worth ~1.3x on per-Exec latency. But it is
      not what stops throughput scaling.
    3. #262's "sweep to a memory/process ceiling" is moot as posed. Nothing here came near a
      memory or CPU limit — Sigma PSS peaked at 59 MB and CPU at 18%. The limit is a rate.
    4. The one thing this sweep cannot settle: whether fixing the 20 ms poll moves the knee, or
      merely makes each restore cheaper up to the same knee. At 4 slots the sleep is ~90% pure
      overhead, so a restore should fall 27.7 -> ~5 ms and replenishment get ~5x faster. Whether the
      1722 ms at 64 slots is caused by the slow cycle (slow restores -> more restores in flight ->
      more contention, a feedback loop) or by an independent bottleneck cannot be distinguished from
      this data. vmpool: waitForUnixSocket's fixed 20ms retry is 90% of every restore (TDD) #304 is therefore both the fix and the experiment; re-run this exact sweep after
      it and the answer falls out.

    Confirms #313's choice of 16

    16 is not merely the largest slot count measured, it is the peak. 32 slots is measurably worse
    than 16 (120.49 vs 170.92), so microvmDefaultConcurrency = 16 is the right default on this host
    for reasons stronger than "the edge of the evidence".

    Reproducing

    Evidence archived on the box at ~/task13-slots-evidence.tgz (89 MB: the 5 rung records, the
    ladders, and the worker logs carrying every phase line). Scripts: ~/task13-lib.sh,
    ~/task13-sweep.sh, ~/task13-report.py. Checkout ~/task13-slots at e170ae0.

    Note analyze_slice fails on each run with detectKnee: no c=1 baseline point — expected, since
    a single-rung ladder has no c=1 point, and the knee being sought here is across slot counts
    rather than across c within one ladder. The rung records themselves are complete; the table
    above is read from them directly.

    No numbers written to EXPERIMENTS.md in this pass.

  5. pdettori commented on Sep 21, 2026

    @pdettori
    MemberAuthor

    CORRECTION: the slot sweep above is confounded — retract the knee, keep the restore finding

    I have to walk back the central claim of my previous comment. The 16-slot knee and the
    collapse beyond it are not attributable to slot count.
    A lurking variable moved with the
    independent variable, and it was mine.

    The confound

    Every Exec leaks one per-VM cgroup directory (issue #255: firecrackerVM.Destroy kills, reaps
    and os.RemoveAll(jailRoot), but nothing on the normal destroy path rmdirs the cgroup jailer
    created; only SweepOrphans does, at startup). My between-run cleanup killed the processes in
    those cgroups but never removed the directories.

    The sweep ran ascending — 4, 8, 16, 32, 64 — with no cgroup cleanup, so stale count grew
    monotonically with the very variable being swept:

    run slots stale vm-* cgroups at start
    1st 4 ~0
    2nd 8 ~1,600
    3rd 16 ~4,900
    4th 32 ~11,400
    5th 64 ~24,400

    By the end of the session there were 47,940 stale directories under microvm.slice.

    Measured causally, not inferred

    Three runs of the same configuration — one worker, 16 slots, 400 iters/slot:

    run stale cgroups at start Exec/s sockwait mean
    ctl1 ~41,000 25.84 1007.98 ms
    ctl2 — identical config, cgroups removed 0 136.51 97.96 ms

    Removing 47,940 directories and changing nothing else recovered 5.3x. So the sockwait
    growth I attributed to concurrency is substantially cgroup-creation cost: the kernel serialises
    cgroup create/destroy, and a firecracker that starts slowly binds its API socket slowly.

    It also explains the signature I flagged as odd but did not chase: the host sat 88% idle
    while throughput collapsed. Nothing was computing; everything was waiting on cgroup operations.

    What survives, and why

    The c=4 run was first, on an essentially clean box (0 stale), and c=8 ran with ~1,600 — at
    which there is no measurable effect (sockwait 24.92 vs 24.11 ms). Those two points stand, and
    they carry the finding that matters:

    • restore total 27.73 ms, of which sockwait is 24.92 ms (89.9%), over 2.80 ms of
      real work (prep 0.22 + wsimg 0.05 + jailer 0.39 + loadsnap 2.14);
    • 0 of 1,625 restores finished inside one 20 ms quantum (min 20.06 ms), 78.2% in [20,40),
      21.8% in [40,60).

    That is a quantization proof and it is independent of accumulation. #304's case is unaffected.

    What is retracted

    • The knee at 16. Unknown. It may be real, but this sweep cannot show it.
    • "Acquire grows 225x because replenishment cannot keep up." The growth is real; the cause
      is now at least partly cgroup accumulation.
    • "The ~800 Exec/s extrapolation is refuted." Withdrawn — it rested on CPU staying flat above
      the knee, and that regime is contaminated.
    • The multi-worker arms (2x16, 4x16). Invalid; they ran on the heaviest accumulation. The
      per-worker environment itself is not at fault — ctl2 reached 136.51 inside that same
      environment. (Separately, the 4-worker arm lost 2 of 4 workers to the driver's 60 s
      attach budget, blown by four simultaneous Go builds and standby fills.)

    Also note ctl2's 136.51 on a clean box is below the 170.92 recorded for c=16 at ~4,900 stale,
    which a pure accumulation story does not predict. So there is run-to-run variance or a further
    factor I have not isolated, and I am not presenting 136.51 as "the" clean 16-slot figure either.

    The re-run that would settle it

    1. rmdir the stale cgroups between runs — find <slice> -depth -type d -name 'vm-*' -delete
      (rmdir, never rm -rf: they are kernel-backed).
    2. Run the ladder descending or randomized, so accumulation cannot correlate with slots.
    3. Record the stale count at the start of every rung, so the confound is visible in the record
      rather than reconstructed afterwards.

    If the knee survives that, it is real. My apologies for the noise on the earlier comment — the
    raw measurements in it are accurate, the attribution was not.

  6. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Task 1.3 re-run: the knee does not exist. Throughput rises monotonically to 64 slots.

    srv-r16b14s16, microVM arm, slots == c, 400 iters/slot, D=2, 256 MiB guests, Go exec client,
    SH_DIAG_PHASES=1, with #255 and #304 both in. Run descending (64 first), cgroup
    directories rmdir'd between rungs, and the stale count recorded at every rung start.

    slots Exec/s vs the retracted series p95 ms coresBusy/72 host CPU cold rate
    64 232.63 3.90x (59.69) 487.2 24.99 34.7% 0.508
    32 163.93 1.36x (120.49) 364.3 17.28 24.0% 0.513
    16 153.08 0.90x (170.92) 157.9 13.75 19.1% 0.233
    8 98.72 0.92x (107.03) 106.1 7.75 10.8% 0.204
    4 57.10 0.94x (60.80) 94.8 4.15 5.8% 0.195

    232.63 Exec/s is the highest figure measured on this host — against a previous best of 172.88,
    and 182.79 on the single-rung check after #255. No Exec errors and zero restore timeouts at
    any slot count (the old c=64 took 396).

    The confound is gone, and checked rather than assumed

    • 0 stale vm-* cgroups at every one of the six rung starts.
    • c=4 repeated LAST: 57.60 Exec/s against 57.10 for c=4 in the descending series — 0.9% apart.
      That repeat is the cheap check the first attempt lacked; it would have caught the artifact in
      three minutes.
    • Descending order means any residual accumulation would work against the high-slot rungs. They
      are the ones that improved.

    What binds now: Destroy

    slots Acquire Resume Run Destroy total slots/total measured
    64 69.97 28.20 4.98 164.27 267.43 239.3 232.63
    32 63.90 25.87 4.50 95.31 189.59 168.8 163.93
    16 7.23 24.76 4.30 65.06 101.35 157.9 153.08
    8 3.85 23.78 4.11 46.92 78.66 101.7 98.72
    4 3.70 23.47 4.01 36.77 67.95 58.9 57.10

    throughput = slots / per-Exec total still predicts every point within 3-4%. Run is flat at
    ~4-5 ms and Resume at ~24-28 ms, while Destroy grows 4.5x across the sweep and is 61% of an
    Exec at 64 slots.
    #258 is now the item, un-confounded.

    Restore sub-phases

    slots restores prep wsimg jailer sockwait loadsnap total share timeouts
    64 25,985 0.29 0.30 0.69 299.06 4.01 304.35 98.3% 0
    32 12,993 0.27 0.15 0.53 189.51 3.21 193.67 97.9% 0
    16 6,497 0.25 0.12 0.51 61.23 2.53 64.65 94.7% 0
    8 3,249 0.23 0.06 0.43 30.71 2.27 33.71 91.1% 0
    4 1,625 0.22 0.05 0.39 22.24 2.18 25.09 88.7% 0

    sockwait is still the restore, and #304 bought only ~11% at 4 slots (24.92 -> 22.24 ms). The
    5x estimate on that issue was an inference from the old quantized distribution and is now
    falsified — see #315. The socket genuinely takes ~10-40 ms to appear on this box.

    Two things this opens

    1. The sweep should extend past 64 slots. 64 is the best point and the host is at 34.7% CPU
      — nowhere near a ceiling, and no longer regressing. 128 and 256 are now meaningful.
    2. Destroy regressed ~14% at low slots (32.28 -> 36.77 ms at c=4), which is the most likely
      cost of fix(vmpool): rmdir the per-VM cgroup on the normal destroy path (#255) #314's cgroup rmdir on the destroy path. Worth confirming, and worth checking
      waitForCgroupEmpty's 10 ms sleep while doing so — that is the same fixed-quantum pattern
      vmpool: waitForUnixSocket's fixed 20ms retry is 90% of every restore (TDD) #304 just removed, sitting in what is now the dominant phase.

    Foreign load over the window: galmasi idle, nothing else on the box.

  7. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Scope annotation for the Exec/s figures in this issue

    Applies to every throughput number published here (62.99 baseline through 593.11). Full detail on #258.

    Each Exec includes two host-initiated vsock connections, both inside the measured phases — one in Resume (mounting /workspace, carrying the wall-clock correction) and one in Run (the command). Neither is amortised and neither can be: Firecracker closes ESTABLISHED vsock connections on resume, so a connection carried across a restore is "a connection to nowhere" (guestconn.go).

    Direction is host→guest only. The host dials the VMM's uds_path and sends CONNECT <port>; the guest agent listens on 1024 and never dials out. So there is no guest→host listener socket and no outbound-from-guest setup in these numbers.

    Recording it so the figures are not read as a narrower measurement than they are.

  8. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    The sweep extended to 256 slots: the peak is 64, and CPU is not the bound

    On merged main (pooled cgroups, #319), srv-r16b14s16, 400 iters/slot, D=2, 256 MiB guests,
    SH_DIAG_PHASES=1. Run descending with the cheapest rung repeated last; drop_caches first so
    the session starts with 0 dying cgroups; SH_MAX_COMMITTED_MB raised to 480 GiB and nofile to
    65536 for every rung, since c=256 commits 216 GiB across 768 VMs and the sudo default of 1024
    fds would have read as spawn failures.

    slots Exec/s vs 64 p95 coresBusy/72 CPU Acquire Resume Run Destroy per-Exec cold errors
    64 549.52 1.00x 161 ms 47.94 66.6% 6.29 32.13 6.05 65.91 110.38 0.158 none
    128 524.66 0.95x 457 ms 50.37 70.0% 74.44 35.15 6.84 117.77 234.20 0.553 none
    256 417.24 0.76x 1244 ms 49.20 68.3% 281.20 39.90 7.97 267.08 596.15 0.698 none
    64 (repeat, last) 577.55 1.05x 145 ms 47.74 66.3% 4.30 32.19 6.10 61.51 104.11 0.142 none

    The ~750 Exec/s extrapolation is withdrawn, this time on clean evidence

    I have now retracted that figure twice. The first time it was a confound (stale cgroups tracking the
    swept variable). This time it is a measurement: CPU sits at 66-70% across a 4x slot range while
    throughput falls. There is ~34% of the host idle that additional slots cannot reach, so scaling
    MaxConcurrent is finished as a lever.

    What binds: the replenishment rate

    Acquire 6.29 -> 74.44 -> 281.20 ms and the cold rate 0.158 -> 0.553 -> 0.698. Past 64 slots,
    demand outruns the rate at which the pool can restore VMs, so acquires go cold and each pays a full
    restore. Destroy grows with it (65.91 -> 267.08 ms) — and with the cgroup cost gone that is
    cmd.Wait under contention, i.e. address-space teardown competing with itself.

    Note this is the same shape as the story #305 told, but it is now true for a different and real
    reason. The earlier version was an artifact of cgroup churn; this one survives with the churn removed.

    Two checks that passed, and one number that did not need raising

    • No session drift. The c=64 repeat is 577.55 against 549.52 for the same rung earlier — 5%
      apart, with the later measurement higher. The host did not degrade across the session, which is
      what perf(vmpool): reuse per-VM cgroups from a pool instead of creating one per VM (#258) #319 was supposed to buy and what every earlier sweep failed.
    • Pooling holds at scale. At c=256, dying cgroups went 0 -> 3 across 102,400 Execs, with 684
      directories recycled. The later per-rung deltas (+683, +320, +164) are each the previous rung's
      pool directories being removed by the next worker's startup sweep — so accumulation is now bounded
      by pool size per worker restart rather than by Exec count. Hundreds, not tens of thousands.
    • The admission gate is correct at scale. 768 concurrent VMs committing 216 GiB, zero Exec
      errors, once the budget was sized for it. Had it not been, the overflow would have arrived as
      failed Execs rather than back-pressure.

    Where the campaign stands

    62.99 -> 577.55 Exec/s on one worker, 9.2x, with the ceiling now the replenishment rate at
    ~66% CPU rather than anything about slots, cgroups, or the socket poll.

    Two items follow, and for the first time they are aimed at the thing that actually binds:

    1. P4 microVM tier: per-Exec VM lifetime is finer-grained than the design needs — worth a separate architecture pass #274 — per-Exec VM lifetime. The only change that attacks both sides at once: fewer restores
      needed per Exec, and Resume + Destroy (94 of 110 ms at the peak) amortised across a session's
      turns rather than paid per command. Worth noting the scope annotation above it too — part of
      Resume is a vsock dial and a guest round-trip for the mount, which is per-connection and
      would amortise as well.
    2. Task 1.4 — multiple workers, now interesting rather than void. One worker peaks at 66% CPU,
      so ~34% is idle and unreachable by more slots. A second worker brings its own pool and its own
      replenish loop, which is precisely the thing that is saturated. The six separations are proven
      (perf(vmpool): reuse per-VM cgroups from a pool instead of creating one per VM (#258) #319 era) and the cheap version is 2 workers x 64 slots against this 577 baseline.
  9. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Fixed and shipped — 2.74x from one constant, and it was the campaign's largest single finding

    Closing. Both halves landed:

    What this turned out to be worth

    configuration Exec/s
    MaxConcurrent=4 (the default this issue found) 62.99
    MaxConcurrent=16 172.88
    64 slots 577.55
    2 workers at 4 each (#259's approach) 123.57

    This issue's central claim — that raising the cap beats adding workers — held, and then strengthened. #259's two-worker result was beaten 1.40x by one environment variable on a single worker, and once the cap is raised a second worker is worth 1.00x (2x32 = 580.58 against 1x64 = 580.60). Scale-out was not merely the worse first move; at the raised cap it is worth nothing on this host.

    What it corrected upstream

    Two published conclusions were reproducible, correctly reported, and meant something other than what they said, because this constant was not in the frame:

    The shipped default is deliberately below the measured peak

    16, not 64, on the principle recorded in #313 that "the default must not wander past the evidence" — 16 was the value with a measured result behind it when it landed. Reaching 64 requires setting WORKER_MAX_CONCURRENT explicitly. Whether to move the default is a separate decision and should weigh p95 (145 ms at 64 slots) and the memory budget, not throughput alone.

    Full record: docs/notes/2026-09-22-exec-throughput-campaign-results.md (PR #327).

    One note for the archive, since this issue was found by reading a goroutine dump: the under-load SIGQUIT dump taken in #303 to rule out a worker-side mutex showed exactly 4 goroutines in session.(*Session).Serve.func5. The answer was visible in that evidence and was dismissed as a sampling artifact. Nothing was waiting because only four things were ever running.

  10. added a commit that references this issue on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions