Description
Summary
vmpool.Exec destroys the VM after every single Exec and never reuses one (P4 §4.1: "runs exactly one command, and destroys the VM before returning. A VM is NEVER reused" — docs/specs/2026-09-09-p4-microvm-sandbox-design.md:304). Since one turn issues many Execs — P4 §3.2 cites operations.ts:78-79, where one file edit alone is two back-to-back Execs with no model round-trip between them — the isolation unit here is the individual command, not the run and not the turn. That's a materially stronger (and more expensive) guarantee than "isolate one run from another," and it's worth asking whether it's the guarantee we actually need.
Why this is deliberate, not an oversight
The design states the rationale plainly, so this isn't a bug report:
| Citation | What it says |
|---|---|
| §3.2 | "This preserves the per-call property exactly — each VM still serves one Exec and dies — while moving creation off the hot path" |
| §4.1 / §6 | "each VM carries its workspace_key and Exec asserts the popped VM matches. Cheap assertion, catastrophic bug [if it ever fails]" |
| §8 | "No VM reuse: The workspace_key assertion holds under concurrency" is a blocking correctness gate |
Per-call destruction bounds the blast radius of any one command's compromise to that command alone, and makes "did this Exec land in the right workspace" a trivial per-VM assertion instead of a stateful one. That's a real security property, not a cost accident.
Why it's worth revisiting anyway
The cost side is exactly what E10/E11 measure: replenishment rate tracks Exec rate 1:1, and that's the dominant term in §7.3's density numbers. A coarser VM lifetime — one VM per turn, or one VM per run — would cut replenishment volume by the average Execs-per-turn (or Execs-per-run) factor, at the cost of a weaker isolation claim ("every turn/run runs in a disposable VM" instead of "every command does"). Whether that trade is worth taking is a product/security call, not an implementation detail, and it should be made explicitly rather than inherited from §3.2's per-call default.
What closing it would involve (not decided here)
- Keep per-
ExecVMs. Status quo, already measured, tightest blast-radius/assertion story. - Per-turn VM lifetime. One VM serves every
Execa singlesession.prompt()call issues. Needs theworkspace_keyassertion (§3.4/§6) redefined against a longer-lived VM, and needs E10/E11 re-measured — the D-standby replenishment model (§3.2, §4.2) is sized around "requests separated by hundreds of ms," which doesn't apply once a VM stops popping mid-turn. - Per-run VM lifetime. Coarser still; changes the isolation claim from per-command to per-run and needs its own threat-model writeup.
Relationship to #267
Separable but adjacent: #267 is about how long the workspace (filesystem) persists; this is about how long the VM process persists. A session-scoped workspace (#267) combined with per-run VM reuse would look different from a session-scoped workspace with per-Exec VMs — worth keeping in mind when either gets designed, but they're independent decisions.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs(e259): correct the recommendation — do not scale out; the cap wa…
docs(e259): correct the recommendation — do not scale out; the cap wa…
docs: publish the Exec/s campaign results and preserve #303's dead ends
docs(vmpool): both replenishment knobs are dead ends, and the reason …
docs(vmpool): both replenishment knobs are dead ends, and the reason …
docs(vmpool): both replenishment knobs are dead ends, and the reason …
pdettori commentedon Sep 24, 2026
Design constraint to settle first: which lifetime unit, and the three timers it sits between
Adding this before anyone starts, because the campaign has now established both the price of this change and a constraint on its shape that is easy to discover too late.
This is now the only remaining lever, not the best one
Every change that reschedules restores has been measured and rejected: more slots (peak is 64, 128 and 256 are worse),
StandbyDepth=8(−20–30%),ReplenishDelay(inside session drift), scale-out to N workers (1.00x), jail pooling (−9.24%), and deferring the teardown (#336 — works, 1.70x on the gate, but only until supply binds). The structural reason is one sentence:So a VM serving n Execs is the only thing left that changes the ratio. Priced from #307 and #337: ~19 ms of unavoidable RCU grace-period latency in
kvm_vm_releaseper VM destroyed, plus ~14 ms of restore work, plus ~35 ms ofResume— of which 78–81% is a guest ext4 mount that #337 showed is CPU-bound in avcpu_count: 1guest and not tunable. Against 4.5 ms for the command itself. A session-scoped VM divides the first three by n and pays the mount once.The constraint: do not introduce a third lifetime
Three lifetimes already exist, and the session owns two of them:
StandbyIdle= 90 s — drop standbys, keep the workspaceWorkspaceIdle= 30 min — delete the workspace tooworkspace_keyis the session id (select-sandbox.ts), so the session — not the run, not the Exec — is already the isolation unit that owns both the workspace and the standby pool. A longer-lived VM should be scoped to the session rather than to some new interval, or the tier acquires a fourth lifetime to reason about and reclaim.Two consequences worth deciding rather than discovering
1. It sharpens the
execGateconstraint #336 just relaxed.execGateis capacity 1 per key, i.e. per session, because the workspace ext4 is not a shared-disk filesystem and two live guests mounting it rw would corrupt it. #336 relaxed when the gate opens — at an/proc/<pid>/fd-empty barrier rather than after the full reap — on the argument that a process with no descriptors cannot write toworkspace.img. A VM that survives its Exec holds that image across more of the turn, so the barrier argument has to be re-made for the new shape. It does not obviously carry over, and it is the correctness property of the tier.2. It interacts with #338. The workspace TTL is already too short for HITL sessions, and a session-scoped VM makes that question sharper: if the VM outlives an Exec, what happens to it across a multi-hour human pause? Holding a VM there is expensive (it is memory, and memory is admission-controlled); dropping it and keeping only the workspace is what the current two-stage policy already does. Whatever #274 decides, it should say which of the three timers governs a surviving VM.
What the design note should answer
execGateinvariant preserved when a VM outlives its Exec. This is the isolation claim; everything else is performance.StandbyIdleandWorkspaceIdle./tmpand/vardiscarded. A reused VM keeps process state,/tmp, environment and installed packages — which is a behaviour change visible to users, not only a performance change, and arguably the biggest thing in this issue.Method note
Measure throughput, not latency, and report p95 alongside. #332's jail pool improved latency 1.6 ms and lost 9.24%; #337's clean-unmount arm improved
mount_us2.86% and lost 4.38% throughput. Two component wins in this campaign have reversed under load, so a latency win with no throughput win is a rejection to record.Refs #307, #336, #337, #338, #332
docs(adr-0035): record that the resident-VM rejection scoped the dens…
docs(adr-0035): per-Exec is the tier's only mode; resident mode not p…
pdettori commentedon Nov 16, 2026
Closing as decided. The ADR-0035 revision of 2026-10-08 settles this issue against reusing a VM across client
Execs: one fresh VM perExecis the tier's only mode, and read coalescing is the one gated exception. The 2026-11-08 note confirms the decision still stands for per-Execmode.The coarser lifetime this issue asked about now exists as an opt-in: SBX lease mode (ADR-0048; #802, #808, #814).
docs: address rossoctl#914 review (the P4 registry row names the page)