Skip to content

feat(vmpool): split the pre-socket window at the jailed execve (#328) - #332

Merged
pdettori merged 3 commits into
rossoctl:mainfrom
pdettori:feat/328-jail-pooling
Sep 23, 2026
Merged

pdettori merged 3 commits into
rossoctl:mainfrom
pdettori:feat/328-jail-pooling

Conversation

@pdettori

@pdettori pdettori commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Splits the restore phase accounting so the pre-socket window says where its time goes, and records why pooling the jail — the fix #328 recommended — was investigated, measured and rejected.

This PR previously contained the jail pool. It was implemented and measured, and it loses ~9% throughput at the operating point, so it has been dropped. The correction is in this comment and the implementation is preserved on archive/328-jail-pool-regression. What remains here is the instrument that found all of it, plus the written record.

The instrument

sockwait was one bucket holding two very different things. The jailer phase timed time.Since after cmd.Start() returned — fork/exec returning, 0.34-1.62 ms across a whole ladder — so the jailer's 6-8 ms of chroot construction landed in sockwait instead. That mis-attribution is why the wait read as "Firecracker is slow to bind" for two rounds of analysis.

The boundary is /proc/<pid>/comm flipping to the jailed binary's name. The jailer execves rather than forking, so cmd.Process.Pid names the Firecracker process too — which makes the flip the execve itself, not a proxy for it. Both filesystem proxies #328 suggested were measured and rejected: firecracker.pid appears 0.20 ms early (the jailer writes it just before the execve), and the jail directory appears at 1.55 ms of a 5.23 ms window.

Result: in-harness, jailer_setup is 93.7% of sockwait and fcbind_us's median is 46 µs. That corroborates #328's 82-85% strace split by an independent method, and in the stronger direction — Firecracker is not the cost.

It cannot distort or break what it measures

Three properties the tests pin, because a bad diagnostic is worse than none:

  • Gated on phaseLog, so no restore pays a procfs read when diagnostics are off — unlike the existing phase clocks, which are ~100 ns and unconditional.
  • Self-disabling after the flip, rather than reading comm for all ~27 poll iterations of a sockwait.
  • Reuses waitForUnixSocket's loop instead of adding a second one. vmpool: waitForUnixSocket's fixed 20ms retry is 90% of every restore (TDD) #304's schedule is the resolution at which anything inside that wait can be measured, so two schedules would make the halves accurate to different quanta and their sum no longer sockwait.

Nothing here can fail a restore: an unobservable boundary reports -1 — never a plausible 0, which would aggregate as "the jailer took no time", the same wrong conclusion the old mis-attribution produced.

fc_bind is right-censored and the note says so: both signals share one 1 ms-capped poll, so when they become visible in the same iteration it reads ~0. It is an upper bound on Firecracker's share and a lower bound on jailer_setup's.

The design note, and why the pool was rejected

docs/notes/2026-09-22-328-jail-pool-design.md is the record. Headlines:

Four corrections to #328's premise, each measured with the previous VMM reaped and the socket deleted first:

  1. --id reuse fails outright unless root/dev/ is wiped (mknod /dev/net/tun: File exists).
  2. The 2× figure was very likely that comment's own leftover socket — two reused attempts agreeing to 17 µs is the signature, and it is what fcJailOccupied exists to refuse.
  3. Pre-creating the jail buys nothing (−3%), and Restore already did it, so the real baseline was not cold.
  4. The jailer re-copies the 3.6 MiB binary every run regardless — reuse avoids allocating the blocks, not the write.

Why it was rejected: latency −1.6 ms (reproducible three independent ways), throughput −9.24% at 64 slots (559.5/556.5/552.3 → 522.0/497.1/505.1 Exec/s, non-overlapping reps). Instrumented, the pool writes ~2.1× more to disk and burns ~12% more CPU: base creates a fresh exec copy and Destroy unlinks it ~30 ms later, so most dirty pages are dropped before writeback reaches them, while the pool keeps the file and the overwrite cannot be elided. Keeping that file was the entire saving, so the saving and the cost are the same decision.

The lesson worth keeping: avoided block allocation lands on the restore's own clock; writeback does not — it is asynchronous and only visible as a rate under load. A component measurement is not a throughput claim, and here the two have opposite signs.

Two security findings outlive the change, which is why the residue analysis is kept even though the code is not: the jailer opens the exec path O_NOFOLLOW, so the symlink form of a root-write primitive is already refused (verified against an intact canary) — but a hardlink is not, and the jail holds our own prep's hardlinks to the golden snapshot, so st_nlink == 1 is what would stop a compromised VMM relinking that path onto memfile and having the next jailer run write Firecracker into the snapshot every VM restores from.

#328's option 2 gets stronger. Bypassing the jailer removes the copy outright rather than relocating it, so it avoids both the allocation and the writeback.

Verification

go test -race ./... green, gofmt clean, go vet clean, make lint and make typecheck green. TestWaitForUnixSocketBackoffGrowsAndIsCapped is load-sensitive (it counts probes in a 200 ms window); confirmed not a regression with 0 failures in 10 interleaved isolated runs and 3 full-suite runs on both this branch and main.

Rig left clean: 0 VMMs, 0 jail directories, 0 stray cgroups under the slice, governor performance and swap off as found.

🤖 Generated with Claude Code

@pdettori
pdettori marked this pull request as draft September 23, 2026 01:46
@pdettori

Copy link
Copy Markdown
Member Author

Correction: the jail pool is a ~9% throughput REGRESSION at the operating point. Converting to draft.

The component result in the PR body is reproducible and I still believe it. It was the wrong thing to conclude from, and a throughput A/B says the opposite. Posting the correction prominently because the PR body currently reads as a win.

Throughput A/B

Identical driver source built against each internal/vmpool, one workspace key per concurrent slot (the launcher sets SerializesExecsPerRun = true, so one key cannot produce concurrent Execs). Arms interleaved and order-swapped per rep.

slots base Exec/s (per rep) pool Exec/s (per rep) median delta
64 559.5 / 556.5 / 552.3 522.0 / 497.1 / 505.1 −9.24%
8 115.4 / 114.9 / 112.8 117.6 / 115.2 / 115.7 +0.70%

The 64-slot reps do not overlap. At 8 slots the arms are indistinguishable.

Mechanism: elided writes become real ones

Instrumented at 64 slots, /proc/diskstats and /proc/stat deltas across the timed window:

arm Exec/s disk written per Exec host CPU
base 534.1 / 549.0 0.16 / 0.12 MiB 42.9% / 42.0%
pool 507.8 / 499.1 0.29 / 0.30 MiB 47.2% / 47.9%

~2.1× the disk writes, ~12% more CPU. It is correction 4 turned around. The jailer rewrites the 3.6 MiB exec copy every run either way, but:

  • base creates a fresh file and Destroy unlinks it ~30 ms later, so most of those dirty pages are dropped before writeback reaches them — only 0.12-0.16 MiB per Exec survives to disk;
  • the pool keeps the file, so the overwrite cannot be elided and writeback has to do it.

Not creating a file you are about to delete is cheaper than reusing one. The pool's entire saving was keeping that file, so the saving and the cost are the same decision — and at a sustained ~550 restores/s the cost is bigger.

Why the component measurement could not see it

Avoided block allocation lands on the restore's own clock, which is why it measured cleanly and consistently at ~1.6 ms three independent ways. Writeback does not: asynchronous, done by kernel threads, charged to nobody's restore, visible only as a rate under sustained load. The instrument was right; the inference from it was wrong, and no additional care with the same instrument would have caught it.

Second time in this issue a latency measurement pointed the wrong way — the first was #328's own sockwait attribution. Same lesson: a component measurement is not a throughput claim.

No cheap fix

  • Pooling the jail without the exec copy was −94 µs, i.e. noise. The binary was the only thing worth pooling and the binary is what costs the throughput.
  • ChrootBase on tmpfs would make the write cheap, but checkDeviceSharing forbids it — the golden snapshot and workspace image are hardlinked in, and hardlink(2) cannot cross devices.
  • Hardlinking the jail copy to the real binary would have the jailer write through it into /usr/local/bin/firecracker, which is the attack verifyExec exists to refuse.

What I suggest

Land the phase split (81639ea) and the design note; drop the pool. The split is independently correct, it is what localised the cost to the jailer, and it is what caught this — jailer_setup at 93.7% of sockwait stands unaffected.

#328's option 2 gets stronger, not weaker. Bypassing the jailer removes the 3.6 MiB copy outright rather than relocating it, so it avoids both the allocation and the writeback. Pooling could only ever move that cost around, which is what it did.

Happy to reshape this into a phase-split-only PR, or leave it as a draft for the record — say which you prefer.

🤖 Generated with Claude Code

…ctl#328)

The instrument, before the fix it exists to measure. The `jailer` phase timed
time.Since AFTER cmd.Start() returned -- fork/exec RETURNING, 0.34-1.62 ms across
a whole ladder -- so the jailer's 6-8 ms of chroot construction was accounted to
sockwait instead. That mis-attribution is why the pre-socket wait read as
"Firecracker is slow to bind" for two rounds of analysis, and it would equally
obscure whether jail pooling worked.

sockwait now splits into jailersetup_us and fcbind_us, and the old jailer_us is
renamed spawn_us to say what it actually measures. sockwait_us is kept unchanged
so rossoctl#328's tables and the campaign notes stay comparable against new runs.

The boundary is /proc/<pid>/comm flipping to the jailed binary's name. The jailer
execve's rather than forking, so cmd.Process.Pid names the Firecracker process
too -- which makes the flip the execve ITSELF rather than a proxy for it. Both
filesystem proxies rossoctl#328 suggested were measured and rejected: firecracker.pid
appears 0.20 ms early because the jailer writes it just before the execve, and
the jail directory appears at 1.55 ms of a 5.23 ms window. On srv-r16b14s16, n=8
cold, this puts jailer_setup at 93% of the pre-socket window and fc_bind at
0.37 ms -- corroborating rossoctl#328's 82-85% strace split by a different method.

Two properties the tests pin, because a diagnostic that distorts what it measures
is worse than none:

  - The observation is gated on phaseLog, so no restore pays a procfs read when
    diagnostics are off, and it self-disables after the flip rather than reading
    comm for all ~27 poll iterations of a sockwait.
  - It reuses waitForUnixSocket's loop instead of adding a second one. rossoctl#304's
    schedule is the resolution at which anything inside that wait can be
    measured, so two schedules would make the two halves accurate to different
    quanta and their sum no longer sockwait.

Nothing here can fail a restore: an unobservable boundary reports -1 -- never a
plausible 0 -- and the restore proceeds on sockwait alone.

Refs rossoctl#328

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
…ossoctl#328)

The investigation behind the phase split, kept so nobody re-runs it.

The pool was designed, implemented and measured. It cuts restore latency by a
reproducible ~1.6 ms -- three independent ways -- and loses ~9.24% throughput at the
64-slot operating point, because keeping the 3.6 MiB exec copy turns writes that
base elides into real writeback: ~2.1x the disk writes and ~12% more host CPU. The
saving and the cost are the same decision, since keeping that file was the entire
saving.

Also records four corrections to the premise in rossoctl#328's third comment, each measured
with the previous VMM reaped and the socket deleted first: --id reuse fails outright
unless root/dev/ is wiped (mknod EEXIST); the 2x figure was very likely timing that
comment's own leftover socket; pre-creating the jail directory buys nothing, so the
real baseline was not cold; and the jailer re-copies the binary every run regardless.

The residue analysis is kept even though the code is not, because anyone retrying
has to answer the same questions and two of the answers outlive the change: the
jailer opens the exec path O_NOFOLLOW, so the symlink form of a root-write primitive
is already refused, but a HARDLINK is not -- and the jail holds our own prep's
hardlinks to the golden snapshot, so st_nlink == 1 is what stops a compromised VMM
relinking that path onto memfile and having the next jailer run write Firecracker
into the snapshot every VM restores from.

The implementation is preserved on archive/328-jail-pool-regression rather than
deleted, and this note says so, since the note's own instruction is not to
re-investigate and the code is that evidence.

rossoctl#328's option 2 gets stronger: bypassing the jailer removes the copy outright rather
than relocating it, so it avoids both the allocation and the writeback.

Refs rossoctl#328

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori force-pushed the feat/328-jail-pooling branch from 63d295a to 44e4b50 Compare September 23, 2026 02:29
@pdettori pdettori changed the title feat(vmpool): pool the Firecracker jail, and split the phase accounting that found it (#328) feat(vmpool): split the pre-socket window at the jailed execve (#328) Sep 23, 2026
@pdettori
pdettori marked this pull request as ready for review September 23, 2026 02:29
@pdettori

Copy link
Copy Markdown
Member Author

Reshaped to the phase split only, and marked ready for review.

Force-pushed, so the commits referenced above are no longer on this branch. The jail-pool implementation — jailPool, verifyExec, the occupancy guard, the --id fix and their tests — is preserved intact on archive/328-jail-pool-regression (63d295a), and the reasoning, the four corrections and the throughput regression are all in docs/notes/2026-09-22-328-jail-pool-design.md in this PR. Nothing from the investigation is lost; it just is not shipping.

Reviewable surface is now 2 commits / 4 files: jail_exec_boundary.go + its tests, ~50 lines of launcher_firecracker.go, and the note.

@esnible esnible left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Two nits below, neither blocking — both are cosmetic/defensive and neither changes a logged value.

I verified the central correctness claim against main: l.opts.FirecrackerBin is the --exec-file passed to the jailer (launcher_firecracker.go:403) and cmd = exec.Command(l.opts.JailerBin, ...) (:415) with a same-pid execve, so filepath.Base(FirecrackerBin) is exactly the comm value after the flip. The boundary detector reads the right name off the right pid.

Things this gets right that are easy to get wrong:

  • TASK_COMM_LEN truncation to 15 chars is handled and tested. Comparing against the untruncated basename would have silently never matched and reported -1 forever — which would have read as "this platform has no procfs."
  • Unobserved reports -1, not 0, and logRestorePhases overrides both fields before formatting, so the meaningless phSock - 0 the caller computes can never reach the log line.
  • Gated on phaseLog != nil and cmd.Process != nil, so the production path constructs no boundary, observe stays nil, and waitForUnixSocketObserved is bit-for-bit the old loop.
  • One poll loop, not two. The reasoning in the comment is correct and non-obvious: two schedules would make the halves accurate to different quanta and their sum would no longer equal sockwait.
  • sockwait_us kept unchanged alongside the split, so #328's existing tables stay comparable.

Two notes, not blocking:

fc_bind right-censoring is disclosed, which I'd otherwise flag. Both signals share one 1 ms-capped poll, so when the flip and the bind land in the same iteration fc_bind reads ~0. The body and the code comments both say so and frame it as an upper bound on Firecracker's share — that's the honest framing. It does mean the headline "median fcbind_us is 46 µs" is a censored median, not Firecracker's actual bind time. Worth remembering before that number gets quoted as a measurement of Firecracker.

The design note is doing real work. §6 ("Dead ends, kept so they are not re-run") and §8's mechanism — base creates a fresh exec copy and Destroy unlinks it ~30 ms later, so dirty pages are dropped before writeback reaches them, while the pool keeps the file so the overwrite cannot be elided — are the kind of finding that otherwise gets rediscovered at full cost. The lesson that a component measurement is not a throughput claim, and that here the two have opposite signs, is the most transferable thing in the PR.

The st_nlink == 1 finding is the most durable item and outlives the rejected code: O_NOFOLLOW refuses the symlink form of a root-write primitive but not the hardlink form, and the jail legitimately holds our own prep's hardlinks to the golden snapshot. That check is documented but not shipped — it deserves its own tracking issue independent of this PR, since the residue analysis is the only place it currently lives.


Assisted-By: Claude Code

// one costs a procfs read per poll iteration, so the production path must not pay it.
var boundary *fcExecBoundary
if phaseLog != nil && cmd.Process != nil {
boundary = newFCExecBoundary(cmd.Process.Pid, l.opts.FirecrackerBin, time.Now())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the boundary's start is a fresh time.Now() taken here, but phSpawn (line 431) was computed by subtraction from phaseStart. So jailerSetup/fcBind partition the interval beginning at this instant, while phSock partitions the interval beginning where phSpawn ended.

The gap is two branches and a struct alloc — nanoseconds, far below the 1 ms poll quantum — so it doesn't affect any conclusion in the PR. But the comment at the log site (line 464) claims the two halves "partition phSock exactly rather than approximately," and strictly they don't. Either derive the boundary start from the same instant phSpawn ends, or soften "exactly" to reflect the sub-quantum skew.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the code rather than in the comment. phSpawn and the boundary now share one clock reading:

spawnEnd := time.Now()
phSpawn = spawnEnd.Sub(phaseStart) - phPrep - phWsImg
...
boundary = newFCExecBoundary(cmd.Process.Pid, l.opts.FirecrackerBin, spawnEnd)

Your diagnosis of where the skew went is exactly right, and it is worth stating because it is not symmetric: fcBind is computed as the remainder of phSock, so the gap was charged entirely to fcBind and none of it to jailerSetup. Sub-quantum, so no number in the PR moves — but it biased the one half that is already right-censored, which is the worse of the two places to put it.

The comment now says the halves partition phSock, without "exactly rather than approximately", since that phrasing was defending a property the code did not have.

setup, seen := boundary.elapsed()
logRestorePhases(req.ID, restorePhases{
prep: phPrep, wsimg: phWsImg, spawn: phSpawn,
jailerSetup: setup, fcBind: phSock - setup, boundaryObserved: seen,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fcBind: phSock - setup is evaluated unconditionally, including when seen is false and setup is 0 — yielding a full-window value for fcBind that is then discarded.

This is correct as written: logRestorePhases overrides both jailersetup_us and fcbind_us with -1 when boundaryObserved is false, so the bogus value can't reach the log line, and TestRestorePhaseLineReportsAnUnobservedBoundaryAsMinusOne pins that. But the struct is momentarily self-inconsistent, and the guard lives one function away. Passing fcBind only when seen would make it correct at the point of construction rather than by downstream override.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The two halves are now set only when the boundary was observed, so the struct is consistent where it is built:

ph := restorePhases{prep: phPrep, wsimg: phWsImg, spawn: phSpawn,
    sock: phSock, load: phLoad, total: time.Since(phaseStart)}
if setup, seen := boundary.elapsed(); seen {
    ph.jailerSetup, ph.fcBind, ph.boundaryObserved = setup, phSock-setup, true
}
logRestorePhases(req.ID, ph)

I kept the -1 override in logRestorePhases rather than replacing it. It is no longer load-bearing for this caller, but it is the invariant enforced at the formatting boundary for any future one, and it is what TestRestorePhaseLineReportsAnUnobservedBoundaryAsMinusOne pins — so removing it would delete the test's subject. The comment now says which of the two is the guarantee and which is defence in depth.

Worth noting the specific badness of the old value, since "bogus" undersells it: phSock - 0 is the entire pre-socket window attributed to Firecracker — i.e. precisely the wrong conclusion this PR exists to make impossible. It could not reach the log, but it was the wrong number sitting in the field.

…verride (rossoctl#332 review)

Two review nits, both about the code being right only because something downstream
rescued it.

The boundary's window now opens at the SAME instant phSpawn ends. It took a second
time.Now(), so the gap between the two -- two branches and a struct alloc -- was
charged to fcBind, because fcBind is computed as the remainder of phSock. Nanoseconds
against a 1 ms poll quantum, so no conclusion in the PR moves, but it made the
comment's claim that the two halves partition phSock exactly untrue. One clock
reading now ends phSpawn and opens the boundary, so the claim holds.

jailerSetup and fcBind are set only when the boundary was actually observed. With an
unobserved boundary the caller computed fcBind as phSock - 0 -- the whole window,
attributed to Firecracker -- and only logRestorePhases' -1 override kept it out of
the log. The struct is now consistent where it is constructed; the override stays as
defence in depth for any future caller, and is still what
TestRestorePhaseLineReportsAnUnobservedBoundaryAsMinusOne pins.

Also labels fcbind_us's 46 us median as CENSORED at the point the note quotes it,
not only in the limitations below it. Both signals are seen by one 1 ms-capped poll,
so when they land in the same iteration it reads ~0 -- it is "at or below the poll
resolution", not a measurement of Firecracker's bind time, and the note now points at
the untraced 0.37 ms from section 2 for that instead.

Refs rossoctl#328

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori

Copy link
Copy Markdown
Member Author

Both nits fixed in 413e9da, replies in the threads. Taking the two non-blocking notes in turn, because the second one got more serious when I checked it.

fc_bind's 46 µs is now labelled censored where it is quoted

You were right that it was disclosed in the limitations and then quoted as a bare number two paragraphs earlier, which is how it would get cited. §7 now says it at the point of use: the figure is censored, read it as "at or below the poll resolution", and if a number for Firecracker's bind time is actually wanted, use the untraced 0.37 ms from §2, which was taken under a tight poll rather than the 1 ms-capped one.

The st_nlink == 1 finding is reachable in main today, not only a constraint on future reuse

I went to write the tracking issue you asked for and found the framing "documented but not shipped" is too generous to the current code. Verified against this branch:

  • Restore's prep does os.Remove + os.Link for the five snapshot components and workspace.img — and nothing at all for the exec copy. root/firecracker is written by the jailer and never touched by us, so it is the one name in the jail with no pre-restore reset.
  • p.seq starts at its zero value per process, so a restarted worker mints vm-1 again.
  • Destroy normally RemoveAlls the jail, so a leftover survives only an unclean VMM death — which is exactly the case the collision guard's own comment says happens (SIGKILL, OOM, crash).
  • Our prep hardlinks the golden memfile into the jail, so inside the chroot that inode is reachable by name. Removing the memfile name on the next restore does not remove a second link planted at another name.

So the chain does not need jail pooling: a compromised VMM, a jail that outlives it, and a worker restart that reuses the id are sufficient, and then the jailer opens that path for writing, as root, before dropping privileges, with O_NOFOLLOW no help because a hardlink is not a symlink.

Calibrating it honestly: it needs a Firecracker VMM compromise first, and the attacker chooses the destination, not the content — the jailer writes the real Firecracker binary — so the impact is integrity/DoS on a host-shared asset, not code execution. Defence-in-depth, not a live remote-triggerable hole.

The fix is one line and needs no pool: have prep os.Remove(filepath.Join(jailRoot, filepath.Base(FirecrackerBin))) before cmd.Start(), exactly as it already does for the other six names. On the normal path Destroy has already removed the jail, so it costs nothing.

I have not opened the issue yet, deliberately. The analysis is above and in §3.2 of the note, but the disclosure venue is yours: a public tracker in this repo (which adds no exposure, since it is already in this PR and your review) or a private advisory. Say which and I will file it — or file it yourself if you would rather own the wording.

On the transferable lesson

Agreed that it is the most portable thing here, and it cost the most to learn: the component number was reproducible three independent ways and I still drew the wrong sign from it. The throughput A/B that caught it took ~15 minutes of rig time, against the two rounds of analysis the original sockwait mis-attribution cost. Cheap check, and I should have run it before offering a number.

@pdettori
pdettori merged commit 8637a7e into rossoctl:main Sep 23, 2026
13 checks passed
@pdettori
pdettori deleted the feat/328-jail-pooling branch September 23, 2026 13:25
pdettori added a commit that referenced this pull request Sep 24, 2026
…es throughput (#307)

Resume was the last opaque phase on the execGate-held critical path. It does NOT
yield a multiple, and this records why so the search stops here.

The decomposition is stable across a descending 8->64 slot ladder (anchor drift
+0.07% on resume, +0.05% on mount): vmresume 1.5-3.4%, vsockdial 16-18%, and
mount 78-81%. vmresume is sub-millisecond, so the vcpu un-pause is not the cost.

THE LEADING HYPOTHESIS IS HALF RIGHT. The workspace ext4 really is never cleanly
unmounted -- needs_recovery is set on a real leftover image, and a host loop-mount
logs "EXT4-fs: recovery complete" -- but recovery is only 0.55 ms of a 19.3 ms
mount. Note that Filesystem state reads "clean" in both cases: for a journaled
ext4 the dirty bit is the needs_recovery feature flag, not s_state, so reading
Filesystem state alone says the fs is fine when it is not.

The fix the hypothesis implies is a measured REGRESSION: -4.38% throughput at 8
slots, p95 +4.8%. Tested with no code change by passing the unmount as the user
command, which lands it on the same gate-held path, with a dumpe2fs probe per arm
proving the arm applied rather than silently failing. It joins the jail pool
(#332, -9.24%) as a component win that reverses under load.

The remaining ~13 ms is not spawn, transport or metadata volume -- host mount cost
moves only 5568->5006 us across an 8x size and 128x inode-count change. Against a
geometry-insensitive ~5 ms host floor and vcpu_count: 1, the mount is CPU-bound in
the guest on a fixed ext4 path. Removing the term needs a substrate change
(virtio-fs, as the CHV launcher already uses), not a tweak.

One cheap win is identified and NOT implemented here: both vsock dials happen
AFTER the resume, so the "two dials are unamortisable" constraint -- which forbids
carrying a connection ACROSS a resume -- does not force two. Folding the mount
into wrapCommand's prologue removes one dial and one round trip, ~2.5 ms of a
31.2 ms Exec. It must be measured as throughput before it is believed.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
pdettori added a commit that referenced this pull request Sep 24, 2026
…empty result

Salvaged from the #331 handoff note, whose thesis #332 refuted. These four are
recorded in neither #332's design note nor anywhere else on main, and they share
a shape worth naming: the instrument reports something plausible, so a clean
number is indistinguishable from a broken probe.

- `RESULTS=` is the only name for a per-rung results dir. There is no
  SH_E11_RESULTS_DIR; an unrecognised name is silently ignored, every rung falls
  back to the default .results/, and the worker log is TRUNCATED per invocation.
  An eight-rung ladder can exit 0 everywhere and yield phase data for one rung.
  This cost a full ladder.
- `sched_schedstats` is off on this host, so /proc/<pid>/sched carries no
  se.statistics.* fields. A probe reading wait_sum to detect CPU starvation
  measures nothing and reports nothing, which reads as "never starved".
- Never time `sudo <thing>`: it is setuid doing PAM work and accounted for ~13 ms
  of a 16 ms reading. Also calibrate the harness, because each $(date +%s%N) is a
  fork+exec and puts the floor of a shell-timed measurement at ~2.4 ms — the same
  order as phases worth measuring.
- A leftover socket reads as this run's socket coming up, because
  waitForUnixSocket dials. fcJailOccupied exists to refuse exactly this and its
  comment says so. The signature is repeated attempts agreeing far too closely:
  two runs within 17 us is a constant, not reproducibility. One measurement
  reported a 2x jail-reuse win on that basis; the real figure was -31%, and the
  change it motivated cost 9% throughput.

Cross-references section 3a for the existing kill-by-cgroup-or-port guidance and
adds that pgrep -f self-matches through its own ssh and sudo argv.

Refs #328 #332

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmpool: the pre-socket wait is 82-85% JAILER chroot construction, not Firecracker (which binds in ~1.5ms)

2 participants