Skip to content

P4: decompose resume (28.58 ms) and destroy (21.31 ms) into their sub-costs #258

Closed

Description

@pdettori

Summary

E10's rung 2 measured the warm hot path as acquire 0.00 ms · resume 28.58 ms · run 2.85 ms · destroy 21.31 ms · total 55.32 ms (authoritative metal run, srv-r16b14s16, 2026-09-15). Resume + destroy are 49.9 of the 55.3 ms and are the entire reason the design's §7.2 stopping rule reads STOP at the 15 ms bar. Right now each is a single black-box number. This issue is about instrumenting both operations internally to find out what inside each is actually expensive, so engineering effort (and any future spec) can target the right sub-step instead of guessing.

Why this matters

  • This is the single highest-leverage item in the epic (#256): whatever the eventual latency bar (15, 60, or something else), reducing resume/destroy is the only lever that helps and doesn't require giving up per-Exec isolation (see the epic's "explicitly out of scope" note on parked-shell reuse).
  • It likely has a second effect on throughput: replenishment (async standby rebuild) performs a similar restore-shaped operation at a similar order of cost (10.98 ms CPU / ~23 ms wall per restore, from E10 rung 3's "replenish" mode). If resume is what dominates a restore's wall-clock cost, cheaper resume could also push out the c=8 replenishment knee measured in E11 — worth confirming rather than assuming.

What's already known / where to look

  • Relevant code: remote-worker/internal/vmpool/launcher_firecracker.go (the VM lifecycle methods — see also the file's comments on SnapshotDir restore and the hardlinked memfile sharing trick), remote-worker/internal/vmpool/fcapi.go (the Firecracker API calls — LoadSnapshot, pause/resume, the mem_backend config), remote-worker/internal/vmpool/pin_linux.go (PinMemoryFile — the MAP_SHARED+mlock of the golden snapshot's memfile that every VMM then maps MAP_PRIVATE).
  • Raw data for the current (undecomposed) numbers: E10 rung 2's parked and freshchild JSON records. Parked vs. fresh-child resume times are nearly identical (28.58 vs 28.56 ms), which already rules out "shell-spawn cost inside the guest" as the dominant factor in resume — the cost is almost certainly in the VM-level restore/teardown machinery itself, not guest-side work.
  • Candidate sub-costs to isolate for resume: the Firecracker LoadSnapshot API call latency itself; mount-at-acquire (the workspace ext4 image mount — see SerializesExecsPerRun in launcher_firecracker.go); vsock device attach/handshake; jailer/cgroup process spawn; first-touch page faults against the pinned memfile even though it's mlocked (the guest's own page tables still need populating on first access, separate from host page-cache residency).
  • Candidate sub-costs for destroy: SIGKILL + process reap; per-VM cgroup teardown (cgroup.go — note the caution there about rmdir vs rm -rf, and see issue microVM: two empty dirs leak per VM id, and a sudo-glob hazard when probing jail internals #255 for a related leftover-directory finding from the same run); jail/workspace directory cleanup; munmap/munlock bookkeeping if any of it is per-VM rather than shared.

Open questions for the spec

  1. What's the right instrumentation approach — in-process phase timers (cheapest, but adds overhead that could itself skew a 20-30 ms measurement), strace/perf at the syscall level, or a flame-graph profiling pass on a representative run?
  2. Should this run against the existing E10 driver (deploy/microvm/e10-lifecycle.sh) with added timing hooks, or does it need a dedicated micro-benchmark that isolates resume/destroy from the rest of the lifecycle?
  3. Is any part of the cost fixed/unavoidable (e.g., a Firecracker API round-trip floor) vs. tunable (e.g., mount options, cgroup hierarchy depth)?

Suggested scope for a first cut

Add phase-level timing inside the resume and destroy code paths (or wrap them with a profiling harness) for one representative rung, and report a breakdown table analogous to E10's existing acquire/resume/run/destroy split, but one level deeper.


Part of rossoctl/moca-experiments#3 (P4 epic: next experiments after the metal STOP).

Activity

  1. pdettori commented on Sep 17, 2026

    @pdettori
    MemberAuthor

    Epic: rossoctl/rossoctl#2546 (Stream 2 — microVM sandbox tier, via sub-epic rossoctl/serverless-harness#256)

    Status update (2026-09-17)

    Still open, no PR yet. E10's own rung-2 decomposition (recorded in
    deploy/microvm/EXPERIMENTS.md) is the starting point this issue should build from:

    acquire 0.00 ms   resume 28.58 ms   run 2.85 ms   destroy 21.31 ms   total 55.32 ms
    

    Resume and destroy are 90% of the rung, with resume itself already known to be
    Restore()-bound and destroy SIGKILL+jailer-teardown-bound — this issue's job is to
    split each of those further.

    Assisted-By: Claude (Anthropic AI) [email protected]

  2. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Destroy is now the dominant per-Exec phase, measured un-confounded

    Task 1.3's re-run (full data on #305) puts this issue at the front. With #255 and #304 in, cgroups cleared between rungs and the ladder run descending:

    slots Acquire Resume Run Destroy total Destroy share
    4 3.70 23.47 4.01 36.77 67.95 54%
    16 7.23 24.76 4.30 65.06 101.35 64%
    64 69.97 28.20 4.98 164.27 267.43 61%

    Run is flat at ~4-5 ms and Resume at ~24-28 ms across a 16x concurrency range. Destroy grows 4.5x. And throughput = slots / per-Exec total predicts every measured point within 3-4%, so this phase is directly on the throughput path, not just latency.

    Two specifics for whoever takes it:

    The plan's Task 3.1 sub-phase split (kill_us, wait_us, removeall_us, plus now cgroup_us) is the next measurement.

  3. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Task 3.1: Destroy decomposed. cmd.Wait dominates at low concurrency; the cgroup rmdir dominates at high, and it is not the cost I predicted.

    Instrumentation on PR (branch feat/258-destroy-subphases), read on srv-r16b14s16 at three
    slot counts — 400 iters/slot, D=2, 256 MiB guests, with #255, #304 and #315 in.

    slots Destroys kill wait removeall cgroupwait cgrouprmdir total
    4 1,625 0.01 33.91 1.08 0.04 2.15 37.19
    16 6,497 0.01 48.30 1.47 0.05 15.53 65.36
    64 25,985 0.03 55.65 1.75 0.07 195.52 253.02

    The five sub-phases sum to the total exactly at every point, so there is no unmeasured residue.

    Prediction scorecard (recorded before measuring)

    predicted actual
    wait_us dominant, 50-60 ms at c=16 48.30 ms, 74% of Destroy right, and right about the mechanism
    kill_us negligible 0.01-0.03 ms right
    removeall_us < 1 ms 1.08-1.75 ms close; right order
    cgroupwait_us ~ 0 0.04-0.07 ms right — waitForCgroupEmpty's fixed 10 ms never fires, because cmd.Wait has already reaped the VMM
    cgroup work ~4.5 ms combined 2.19 -> 15.58 -> 195.59 ms wrong, and it is the whole story at scale

    wait_us is the fixed cost and it barely scales: 33.91 -> 55.65 ms, only 1.6x across a 16x
    concurrency range. That is consistent with the predicted mechanism — a SIGKILLed Firecracker
    holding a 256 MiB MAP_SHARED mapping needs that address space torn down before it is reaped.

    cgrouprmdir_us grows 91x (2.15 -> 195.52 ms) and is 77% of Destroy at 64 slots. Cgroup
    removal is kernel-serialised, so 64 concurrent rmdirs contend with each other.

    The reason it scales is worse than contention: dying cgroups

    /proc/cgroups reports 12,670 cgroups while only 89 directories exist host-wide. The
    definitive counter:

    root                 nr_descendants 88   nr_dying_descendants 12582
    microvm.slice        nr_descendants  5   nr_dying_descendants 12403
    microvm-vms.slice    nr_descendants  0   nr_dying_descendants 12399
    

    12,399 dying cgroups under the VM slice, with zero live children. These are directories
    Destroy has already rmdir'd whose kernel structures have not been freed — the memory
    controller keeps a cgroup alive while any page is still charged to it, and jailer is given
    --cgroup memory.max=<PerVMBytes> for every VM, so guest page cache is charged there.

    So #255's fix is necessary but not sufficient. The directory leak is gone (verified: 0 stale
    at every rung start, 0 after the run), but a kernel-side accumulation with the same shape of
    consequence remains, and rmdir alone does not reclaim it.

    This is measurable in throughput. c=4 and c=16 reproduce the earlier sweep within 2%, but c=64
    came out 0.78x
    (182.50 vs 232.63 Exec/s) — and it ran last here against first in that
    sweep, with Destroy 254.26 vs 164.27 ms. The per-rung stale-directory count was 0 every time,
    so this is not the old confound; it is the dying-cgroup population the session accumulated.

    Consequence for measurement: cgroup cost depends on cumulative VMs since boot, not since
    worker start. Any high-concurrency figure is therefore order-dependent within a session, and the
    per-rung stale-directory count is no longer a sufficient confound check. nr_dying_descendants
    should be recorded per rung alongside it.

    What to do about it, in order of appeal

    1. Take the rmdir off the Exec's critical path. Nothing requires the cgroup to be gone before
      the next Exec starts — the execGate constraint is about the workspace image mount, not
      the cgroup. Deferring to pool.reclaimLoop (which exists) would cut ~195 ms from Destroy at
      64 slots without changing what work is done. This is plan Task 3.3's question, now with a
      number attached.
    2. Force the charges out before rmdir so the kernel can actually free the structure — write
      to memory.reclaim, or set memory.max=0 first. This attacks the accumulation rather than
      the latency, and the two are independent fixes.
    3. Stop churning cgroups per VM. The pool already pools VMs; a cgroup per slot rather than
      per VM would remove ~26,000 create/destroy cycles per rung entirely. Larger change.

    (1) and (2) are complementary and both testable on this rig. (1) is the throughput win; (2) is
    what stops the box degrading over a session.

    wait_us remains the floor once those land: ~34 ms at c=4, and the plan's step 4 question about
    the guest-side unmount is answered by removeall_us being 1-2 ms — the workspace image unlink is
    not forcing a costly flush.

  4. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Task 3.3 tested: deferring the cgroup rmdir does NOT work. Reverted, with the evidence.

    I built the deferral (bounded queue, 4 background workers, inline fallback on a full queue) and
    measured it. It works mechanically and is the wrong change. Reverted in ea6e1ad; the
    instrumentation from Task 3.1 stays.

    The time is conserved across phases, which is what settles it

    slots phase before after delta
    16 Destroy 65.65 ms 50.89 ms -14.76
    16 Acquire 7.42 ms 21.83 ms +14.41
    16 per-Exec total 102.18 ms 101.55 ms -0.63
    16 throughput 152.49 150.05 0.98x
    64 Destroy 254.26 ms 175.32 ms -78.94
    64 Acquire 57.82 ms 159.01 ms +101.19
    64 per-Exec total 342.93 ms 367.08 ms +24.15
    64 throughput 182.50 170.05 0.93x

    At 16 slots the 14.76 ms removed from Destroy reappears as 14.41 ms in Acquire. At 64 slots it
    is worse than conserved — 79 ms out, 101 ms in, a net 24 ms loss.

    The bottleneck is not where the cgroup work sits; it is the total rate of cgroup operations the
    kernel will sustain.
    Background workers create no capacity. They relocate the contention from
    Destroy into the restore path, where removals now contend with cgroup creation during
    replenishment — and a slow restore is strictly worse than a slow destroy, because it starves
    replenishment, which makes acquires cold, which is the amplifying loop of #305. sockwait rose
    59.81 -> 83.94 ms at 16 slots and 382.68 -> 469.75 ms at 64.

    The mechanics were fine, which is the useful part

    • cgrouprmdir_us = 0.00 ms at 4 and 16 slots, with 0 inline fallbacks — fully deferred.
    • 0 leaked directories; the jail still removed synchronously.
    • At 64 slots, 13,171 of 25,985 removals fell back inline: the backpressure path working
      correctly, and also the signal that the queue was never the constraint.

    So the plan's Task 3.3 question — "determine which part of the 33.7 ms actually gates the next
    Exec ... plausibly deferrable to the reclaim goroutine" — is answered, and the answer is no. The
    rmdir is deferrable in the sense that nothing breaks, and deferring it does not help.

    What should be done instead

    Both of these reduce the work rather than reschedule it:

    1. A cgroup per SLOT instead of per VM. At 64 slots that is 64 cgroups for the worker's life
      against ~26,000 create/destroy cycles per rung. It removes the churn rather than moving it, and
      the pool already pools the VMs those cgroups belong to. Largest change, and the one the
      evidence points at.
    2. Force charges out before rmdir (memory.reclaim, or memory.max=0), attacking the ~12,400
      dying cgroups directly so the kernel can free the structures instead of managing them.

    Separately: the 1 ms socket poll cap appears to cost throughput at 64 slots

    c=64 has now been measured three times, and the drop tracks #315's socketPollMax change rather
    than run order:

    run socketPollMax slot order sockwait Exec/s
    sweep2 5 ms 64 first 299.06 ms 232.63
    dsub 1 ms 64 last 382.68 ms 182.50
    defer 1 ms 64 first 469.75 ms 170.05

    The 1 ms cap runs ~27 probes per restore instead of ~9, and at 64 concurrent restores that
    syscall load is not free. Order does not explain it — the 1 ms run that went first was the
    slowest. I would not read the 232.63 as recoverable without testing it, but it is worth one rung
    with the cap back at 5 ms to confirm, and if it holds, a staged cap (fine until ~50 ms elapsed,
    coarser after — the socket appears at 9-40 ms, so probes beyond that are pure waste) would keep
    #315's measurement resolution where it matters without the syscall load on long waits.

  5. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    The 1 ms poll cap is NOT costing throughput. My hypothesis was wrong; #315's cap should stay.

    A/B/A/B at c=64 in one session on one checkout, changing only socketPollMax, alternated so
    session drift could not masquerade as the effect. Chronological order 5ms, 1ms, 5ms, 1ms:

    cap round Exec/s p95 Acquire Destroy per-Exec sockwait probes/restore
    5 ms 1 177.28 613.3 69.81 253.47 353.92 406.90 ~88
    1 ms 1 175.35 631.5 71.93 253.47 356.99 416.80 ~413
    5 ms 2 175.25 645.2 72.23 254.38 357.61 417.96 ~90
    1 ms 2 158.75 706.9 75.39 288.34 395.32 469.22 ~466

    1 ms round 1 is indistinguishable from both 5 ms rungs — 175.35 against 177.28 and 175.25 —
    while running 4.6x more probes per restore. Three of the four rungs sit at 175-177 Exec/s
    regardless of cap. The entire 1.055x difference in the means comes from the final rung, and that
    rung's anomaly is in Destroy (288.34 vs 253-254 everywhere else), not in sockwait.

    So the extra syscalls are real and their throughput cost is not measurable here. Keep the 1 ms
    cap
    — it buys the +-1 ms attribution resolution that #315 needed, apparently for free. No staged
    cap is warranted; I withdraw that suggestion.

    And the 232.63 is not recoverable by either cap

    None of the four rungs came near it. The drop from 232.63 (measured ~2 hours earlier) to ~176 is
    not explained by the cap, which was my hypothesis on #258 and is now falsified. The remaining
    explanation is the one already documented: the box carries ~12,454 dying cgroups and a boot's worth
    of VM history, and cgroup operation cost grows with it.

    That makes the accumulation a ~24% degradation of this host at high concurrency, on top of being
    the confound that invalidated the first sweep. It is no longer just a measurement hazard.

    Consequence for how this campaign measures

    Any c=64 figure is only comparable to another taken at a similar dying-cgroup population. Recording
    nr_dying_descendants per rung (already recommended) is necessary but not sufficient — it does not
    make two runs comparable, it only makes them interpretable. A clean high-concurrency baseline
    needs a reboot, which on this shared box needs coordinating.

  6. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Reclaim-before-rmdir: the mechanism works, the cost makes it unusable. Dead end, measured.

    Built behind SH_CGROUP_RECLAIM_ON_DESTROY=1, A/B'd at c=64, and removed. No PR.

    It does fix the accumulation

    nr_dying_descendants under the VM slice, across each rung:

    reclaim before after delta
    ON 13,863 13,799 -64
    OFF 13,799 13,872 +73
    ON 13,872 13,808 -64
    OFF 13,808 13,872 +64

    Dying cgroups fall with it on and grow with it off, twice each. The mechanism is sound.

    And it hangs the worker

    Both ON rungs failed. The worker logged exactly one restore and then went silent, never
    attaching within the driver's 60 s budget; both OFF rungs passed. The first destroy on the path is
    pool.Probe's deferred vm.Destroy(), and probeTimeout cancels a context, which cannot
    interrupt a blocking write(2).

    Measured directly on a cgroup charged with a VM-sized dirty working set:

    request charged time
    memory.current (617 MiB dirty) -> memory.reclaim 617 MiB 1188 ms (left 8 MiB)
    bounded 1 MiB -> memory.reclaim 626 MiB 10 ms

    ~1.2 s of synchronous writeback per VM, on a path that runs once per Exec. A bounded request
    is cheap and pointless — it does not free the cgroup, which was the whole object.

    There is no out-of-band version either

    Reclaim needs the cgroup to still exist, so it cannot happen after the rmdir. Doing it before, in
    the background, means deferring the rmdir as well — and that was already measured to relocate
    cgroup contention into the restore path rather than remove it. This would add 1.2 s of writeback
    per VM on top of that.

    One incidental finding, and it points at the fix

    Re-reading the golden snapshot from inside a fresh cgroup charged it 0 MiB. Those pages were
    already resident and charged to whichever cgroup first faulted them — the shared-page-cache
    mechanism that pins dying cgroups, confirmed directly rather than inferred.

    That is also the argument for the remaining candidate: a pooled, long-lived cgroup ends the
    accumulation at source with no reclaim work at all
    , because the snapshot's page cache stays
    charged to something that never dies.

    So of the two candidates from the decomposition, the cheap one is now closed and the remaining one
    is load-bearing: stop creating a cgroup per VM. --cgroup memory.max= is what creates it and
    --parent-cgroup alone only relocates the process, so a pool of reusable cgroups removes the
    rmdir cost, the reclaim problem, and the dying-cgroup accumulation together. It needs a design note
    first — unit of reuse (VM ids outnumber slots because of standbys), SweepOrphans' vm-N name
    recognition, and charge inheritance between successive tenants of one cgroup.

  7. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Correction: the reclaim hang's stated mechanism is withdrawn

    Following #318's review precondition, I sampled live vm-N cgroups during a c=64 rung — and it undercuts the explanation I gave for why the reclaim experiment hung.

    signal 306 samples, 40 cgroups
    memory.events max/high/oom 0 non-zero
    memory.current mean 0.9 MiB, max 2 MiB (limit 288 MiB)
    memory.stat file / anon / dirty all ~0

    I attributed the hang to ~1.2 s of synchronous writeback per VM. That figure came from a synthetic cgroup I deliberately charged with 617 MiB of dirty page cache — a real VM cgroup holds ~1 MiB, so the mechanism does not transfer.

    What stands: the flag reliably broke startup. Two ON rungs failed with the worker never attaching inside 60 s; two OFF rungs passed; nothing else differed. The removal is justified by that.

    What is withdrawn: the explanation. The cause is now open.

    Two more things the same measurement settled, both good news for the pooled-cgroup design (#318):

    • The per-VM memory.max never binds — 0 of 306 samples anywhere near it. My earlier suggestion on this issue that it might already be forcing reclaim of the guest's working set is false.
    • VM cgroups do not hold the snapshot's page cache. PinMemoryFile mlocks memfile at worker startup, and the snapshot is hardlinked so it stays a single shared page-cache object — so a guest's MAP_SHARED mapping of already-charged pages charges the VM nothing. That makes reuse compatible with keeping the per-VM limit, so docs(258): design note for pooled VM cgroups, with the decision it needs #318 keeps D1 intact rather than trading it away.

    New loose end: if each cgroup holds ~1 MiB, what pins 12–13k of them as dying is not obvious. Pooling makes it moot by not creating them, but it is unexplained and recorded as such.

  8. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Scope annotation for every Exec/s figure in this issue (and #305)

    Raised in review and it applies retroactively to all the throughput numbers published here —
    62.99, 232.63, 579.16, 593.11 and everything between. Recording it so nobody reads them as a
    narrower measurement than they are.

    Each Exec includes TWO host-initiated vsock connections, both inside the measured phases:

    phase ms at c=64 (pooled) vsock work
    Resume 32.27 dial #1 — mounts /workspace (mountpoint -q /workspace || mount -o rw,noatime /dev/vdb /workspace) and carries the wall-clock correction in the same request
    Run 6.17 dial #2 — the command itself

    Neither is amortised, and neither can be. From guestconn.go:

    Firecracker documents that listening vsock sockets survive restore (with the CID updated) while
    ESTABLISHED connections are closed on resume (spec §2.4), so a connection carried across a
    snapshot boundary is a connection to nowhere.

    So the code opens a connection after resume and never reuses one across a restore. Since a VM
    serves exactly one Exec today, that is two full dials per Exec, every time.

    Direction: host → guest only. dialVsock connects to the VMM's uds_path and performs
    Firecracker's host-initiated handshake:

    conn, _ := net.DialTimeout("unix", path, 10*time.Second)
    fmt.Fprintf(conn, "CONNECT %d\n", port)   // guest agent listens on 1024
    line, _ := br.ReadString('\n')            // expects "OK <cid>"

    The guest never dials out, so there is no guest→host listener socket (<uds_path>_<port>) in
    play and no outbound-from-guest setup in any of these numbers.

    Why it matters beyond bookkeeping

    It changes what Resume's 32.27 ms is made of. That is not just Firecracker's socket bind — it is
    bind plus a vsock dial with a round-trip handshake plus a full guest round-trip for the
    mount. Worth decomposing before treating it as irreducible.

    It also sharpens #274. A VM serving more than one Exec would amortise the /workspace mount and
    one of the two dials, not merely the ~56 ms cmd.Wait teardown — so the amortisable share of an
    Exec is larger than the earlier "86% is Destroy+Resume" framing implied, because part of Resume
    is per-connection rather than per-VM.

  9. added a commit that references this issue on Sep 22, 2026
  10. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Pooled cgroups verified at 4x the concurrency, and the ceiling located

    Extended the sweep to 256 slots on merged main. Full table on #305; the parts that belong here:

    Pooling holds at scale. At c=256, nr_dying_descendants went 0 → 3 across 102,400 Execs, with 684 pool directories recycled throughout. The later per-rung deltas (+683, +320, +164) are each the previous rung's pool dirs 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. That is the half of #319 that makes future measurements trustworthy, and it is the first sweep in this campaign with no session drift: the c=64 anchor repeated last came in 5% higher than the same rung earlier.

    Destroy is now cmd.Wait and nothing else that matters. At the 64-slot peak it is 61.51–65.91 ms, and the cgroup release is ~0.047 ms. It still grows with concurrency (66 → 118 → 267 ms at 64 → 128 → 256), but with the cgroup cost removed that growth is address-space teardown contending with itself, not bookkeeping.

    What this closes for #258. The phase this issue was opened about — "decompose resume and destroy into their sub-costs" — is decomposed, and the largest sub-cost found (the per-VM cgroup rmdir, 195.52 ms at 64 slots) is eliminated rather than relocated. Two cheaper fixes were built, measured and rejected on the way, both recorded above with their evidence.

    What remains of the original 93%-is-lifecycle framing is cmd.Wait (~56 ms) plus Resume (~32 ms, of which part is a vsock dial and a guest round-trip for the mount). Neither looks reducible while a VM serves exactly one Exec, which is #274's premise — so I would close this issue in favour of #274 rather than keep optimising inside a per-Exec VM lifetime.

  11. pdettori commented on Sep 22, 2026

    @pdettori
    MemberAuthor

    Done — both operations are decomposed, and the breakdown found more than expected

    Closing. SH_DIAG_PHASES now emits sub-phase timing for both, in launcher_firecracker.go:

    vmpool: restore phases id=… prep_us= wsimg_us= jailer_us= sockwait_us= loadsnap_us= total_us=
    vmpool: destroy phases id=… kill_us= wait_us= removeall_us= cgroupwait_us= cgrouprmdir_us= total_us=
    

    This was correctly ranked the highest-leverage item in rossoctl/moca-experiments#3. It produced four follow-ups that between them account for most of the campaign's 9.2x: #303/#304 (the socket poll), #307 (Destroy), #315, #317 and #319.

    Current breakdown, one worker at 64 slots, srv-r16b14s16 (n = 25,985)

    Destroy — the rmdir this issue flagged as a candidate was real and is now gone (#319 pooled the per-VM cgroups: 195.52 → 0.046 ms). What remains is cmd.Wait:

    sub-phase 64 slots 128 256
    kill 0.55 ms 0.68 1.03
    cmd.Wait 58.94 ms 104.28 240.01
    removeall 5.92 ms 11.23 22.72
    cgroupwait 0.11 ms 0.17 0.46
    cgrouprmdir 0.046 ms 0.067 0.194

    89% of Destroy is waiting for the VMM process to die after SIGKILL. Tracked in #307.

    Restore — this issue guessed at "the Firecracker API round-trip floor" and at "jailer/cgroup process spawn". The answer is neither: it is the wait for the API socket to appear.

    sub-phase 64 slots 128 256
    prep 0.62 ms — —
    wsimg 0.25 ms — —
    jailer 2.18 ms 2.91 4.14
    sockwait 38.07 ms 238.72 869.43
    loadsnap 5.56 ms 8.02 11.47

    LoadSnapshot itself is only 5.56 ms, so the API-floor hypothesis is ruled out. Filed separately.

    Answers to this issue's open questions

    1. Instrumentation approach: in-process phase timers were the right call and the overhead worry did not materialise — six time.Now() calls are ~100 ns against a 20–60 ms phase. No strace or flame graph was needed.
    2. Existing driver vs dedicated micro-benchmark: the existing path, via the ExecPhased/Phases decomposition that already existed and that vmpoolctl already drove — the worker simply never surfaced it. No new measurement machinery.
    3. Fixed vs tunable: both, and the split was not where this issue guessed. The cgroup rmdir was tunable and is now ~0. cmd.Wait and sockwait are neither fixed nor cheaply tunable — they are load-dependent kernel process lifecycle, which is what makes P4 microVM tier: per-Exec VM lifetime is finer-grained than the design needs — worth a separate architecture pass #274 the remaining lever.

    One correction to this issue's framing, recorded because it misdirected early effort: it reads the E10 numbers as resume 28.58 / destroy 21.31 with destroy the smaller. Destroy is in fact the larger term at every configuration measured since.

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions