Repository navigation
docs(microvm): record issue #266's metal/nested ratio (E10+E11 on nested-m8i) - #269
Conversation
…y a captured PID E11_RELAY_PID comes from `pnpm ... start & echo $!` inside a subshell. On a host where pnpm stays running as a supervisor over a separate node child rather than exec-ing into it, killing that PID kills pnpm and leaves the child holding the port. The next arm's own relay then either dies with EADDRINUSE, or worse: its worker's startup check only confirms something answers on the port, never which relay, so it silently attaches to the STALE relay left by the PREVIOUS arm. That is the exact "silently wrong data" failure METAL-RUNBOOK.md section 3a already documents for a leaked relay across separate invocations -- this is the same bug within a single e11-density.sh run, between its own two arms. Caught live during issue rossoctl#266's nested-m8i run: the microvm arm's c=1 data was measured against the container arm's leftover relay before the crash surfaced. Add kill_relay_by_port(), which kills whatever ss reports listening on the relay port (same as the runbook's own manual cleanup recipe), and wire it into both stop_container_stack and stop_microvm_stack alongside the existing PID-based kill. Pin with five regression checks in e11-density.test.sh. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…1 on nested-m8i Repeats the authoritative E10 (ITERS=200 WARMUP=20) and E11 ladders on nested-m8i, per the issue's own suggested first cut, and reports a metal/nested ratio for every field that has a metal baseline on record. Headline findings: - E10: warm hot path is 3.81x metal, but the container baseline moved the opposite direction (0.61x) -- 6.23x of the 8.04x section-7.2 ratio is inherited from a baseline that shifted for reasons unrelated to nesting. Rung 2's decomposition isolates the real signal: destroy is taxed harder than resume (5.56x vs 2.74x), not evenly. - E11: the microVM arm's p95 ratio is a clean ~2x at every c (1.85x-2.60x), while the container arm's p95 ratio hovers near 1x -- a load-independent nested tax on VM-exit-heavy work. The knee lands at the same c=8 on both substrates (issue open question 3), just costing ~2x more once reached. - E10 rung 1 and the whole of E11 ran for the first time on this rig: it now has docker/grpcurl/pnpm (absent as of 2026-09-14). - c=64 is deliberately absent from the E11 sweep: 64 concurrent 256MiB VMs need ~18GiB against this m8i.xlarge's 15GiB, a genuine memory ceiling this rig hits before the replenishment ceiling metal hit at the same c. E10 rung 3/4 have no metal baseline to ratio against -- EXPERIMENTS.md never recorded metal's per-rung JSON, and that box was later wiped -- so they're reported nested-only. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
cwiklik
left a comment
There was a problem hiding this comment.
Two changes in one PR: the issue #266 nested-vs-metal ratio write-up, and a real relay-teardown bug the run surfaced, fixed with regression tests. Both are solid. No blocking findings.
The ratio discipline is the right call and is executed carefully — pricing the microVM arm against a container arm on the same box is what makes the ~2x nested tax credible, and catching that 6.23x of E10's 8.04x §7.2 blow-up is inherited from a baseline that moved for non-nesting reasons is a genuinely useful correction to a number that would otherwise have been read as pure nested tax. The c=64 omission is reported as a finding rather than buried as a gap, which is the right instinct.
I independently re-derived every ratio in all four tables and they all check out. 288 MiB per resident VM verifies against source (DefaultVMOverheadBytes = 32 << 20 in remote-worker/internal/vmpool/config.go:46, plus guestRamMb=256), so the 64 × 288 MiB ≈ 18 GiB argument against a 15 GiB box holds, and SH_MAX_COMMITTED_MB=11264 does clear 32 (9 GiB) with headroom. The recomputed SH_E11_COLD_LATENCY_MS reconciles too: 209.72 + 114.45/2 = 267.
Seven inline comments: two on the shell fix's failure modes, two cosmetic, three on the write-up.
The one I'd most like a second look at is the knee sentence (EXPERIMENTS.md, "the knee lands at the same c on both substrates"). The section otherwise holds the ratio discipline rigorously, and that sentence is the one place it reports a nested number as a load-behavior conclusion — which this same file, ~200 lines earlier, explicitly rules out. Details inline.
Two things I checked and am not raising, recorded so they don't get re-litigated:
- The new
pid="$(ss … | grep -oP …)"pipeline is not aset -e+pipefailabort hazard. This driver runsset -uo pipefailwithout-e(theset -euat line 625 is inside thebuild_converge_scriptheredoc, i.e. the guest script).E11_RELAY_PORTis assigned at line 213, above the trap, soset -ucan't bite the new call sites either. - The
c=8knee is correct, and my first reading that it contradicteddegradeX=2was wrong. Nested p95 first exceeds 2x the c=1 baseline at c=16, but this file defines the knee as the last healthy rung (line 712), and under that rule c=8 is right on both arms.
Areas reviewed: Shell, Docs/Markdown, Tests
Agent/IDE config (.claude/, .vscode/): none — supply-chain gate clear
Commits: 2, all signed off
CI: passing (13 green, incl. shellcheck and deploy-scripts)
| local port="$1" pid | ||
| # shellcheck disable=SC2034 # loop variable is the retry count itself, not read | ||
| for tries in 1 2 3 4 5 6 7 8 9 10; do | ||
| pid="$(ss -ltnp "sport = :${port}" 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1)" |
There was a problem hiding this comment.
suggestion — ss is a new external dependency and isn't registered with require_tool.
This is the only ss in the file (wait_for_relay_port uses bash /dev/tcp instead), so it's a genuinely new PATH requirement. ss is reasonable here — /dev/tcp can't give you a pid, so there isn't a bash-builtin way to do this — but preflight deliberately enumerates every external binary, and its own comment gives the reason:
require_tool refuses a MISSING external binary by name, in preflight, rather than letting a rung "run" against a command that is not there [...] E11 had NO tool preflight at all, and that is why its first-ever execution reported "converge FAILED after 35ms" three times over instead of naming grpcurl
The consequence here is worse than the grpcurl case, because 2>/dev/null swallows ss: command not found: pid comes back empty, [ -z "$pid" ] && return 0 fires, and the function reports success without having looked at anything. The port stays held, the next arm's relay hits EADDRINUSE, its worker attaches to the stale relay — and the run now believes teardown was clean. That is exactly the silently-wrong-data outcome this fix exists to prevent, reachable by a missing binary instead of a wrong pid.
One line closes it, alongside the existing four:
require_tool ss "between-arm relay teardown identifies the listener by port via ss; without it kill_relay_by_port cannot tell a free port from a missing tool, and the next arm would attach to the previous arm's relay"Low likelihood on the intended rigs (iproute2 is installed by default on Ubuntu and AL2023), which is why this is a suggestion rather than a must-fix — but the failure is silent and voids a run's data, and the guard costs one line.
There was a problem hiding this comment.
Fixed — added require_tool ss in preflight() with the exact wording suggested (commit 29adaf5).
| kill -9 "$pid" 2>/dev/null | ||
| sleep 0.5 | ||
| done | ||
| die "port $port is still held by pid $pid after 10 kill attempts - the next arm's relay would bind onto a stale listener or fail with EADDRINUSE (see kill_relay_by_port's comment)" |
There was a problem hiding this comment.
suggestion — this die can abort the EXIT trap partway through.
cleanup_on_exit calls stop_container_stack || true then stop_microvm_stack || true, and the || trues are clearly there so neither teardown can prevent the other. But || doesn't catch exit, and die is echo … >&2; exit 1 — so a die raised from inside stop_container_stack terminates the shell immediately and skips the rest of the trap:
stop_microvm_stacknever runs — worker, relay and firecracker VMs left up;- the
docker rm -f "sh-e11-redis-$$"two lines below never runs; rm -rf "$E11_TMPDIR"never runs, which the trap's own comment calls out as the thing that "reclaims all of them however deep the sweep was when it stopped."
This is the failure class the trap header already names as previously-fixed — "unbound variable INSIDE the trap, which aborts the rest of the trap" — reached by a different route. And the consequence is the one documented right above it: an orphaned firecracker is still matched by discover_pids' unscoped pgrep -f firecracker, so it "silently inflates the NEXT run's pssBytes — the one number spec section 7.3 insists must not be wrong, corrupted in a way that looks like a real density result."
The loud failure is right for the between-arms call sites (lines 1260/1272), where a stale listener really does corrupt the arm about to start. It's wrong for the trap, where best-effort is the whole design. A flag keeps both:
cleanup_on_exit() {
E11_IN_CLEANUP=1
...
}and in kill_relay_by_port, [ -n "${E11_IN_CLEANUP:-}" ] && { log "port $port still held by pid $pid; continuing teardown"; return 1; } before the die.
Agreed this needs a process to survive ten rounds of kill -9 to trigger at all, so it's unlikely — but it's unlikely and it silently corrupts the following run, so it seems worth not leaving to chance.
There was a problem hiding this comment.
Fixed with the E11_IN_CLEANUP flag as suggested — set at the top of cleanup_on_exit, checked in kill_relay_by_port before the die: the trap path now logs and returns 1, the between-arm call sites keep the loud die (commit 29adaf5).
| for tries in 1 2 3 4 5 6 7 8 9 10; do | ||
| pid="$(ss -ltnp "sport = :${port}" 2>/dev/null | grep -oP 'pid=\K[0-9]+' | head -1)" | ||
| [ -z "$pid" ] && return 0 | ||
| kill -9 "$pid" 2>/dev/null |
There was a problem hiding this comment.
nit — two small things on these two lines.
kill -9 fires on the first iteration with no grace window, and both call sites run kill "$E11_RELAY_PID" (SIGTERM) immediately beforehand. The relay will still hold the port microseconds later, so in practice the SIGTERM never gets a chance and every teardown is a SIGKILL — meaning the relay log in $RESULTS/e11-*-relay.log can be truncated mid-write, and those logs are the evidence trail wait_for_relay_port already leans on when it dies. Moving sleep 0.5 to the top of the loop body would give the TERM one interval and cost 0.5 s only when something is actually still listening.
Separately, grep -oP is the only PCRE use in this file. The script is Linux-only by construction (ss, docker, firecracker), so GNU grep is a safe bet in practice; it's just that ss … | sed -n 's/.*pid=\([0-9]*\).*/\1/p' | head -1 needs no -P and matches the file's existing plain-grep/awk idiom.
There was a problem hiding this comment.
Fixed both. Moved sleep to the top of the loop so the SIGTERM sent by both call sites gets a grace window before the first SIGKILL. Swapped grep -oP for sed -n to match the file's non-PCRE grep/awk convention (commit 29adaf5).
| # STALE relay left by the PREVIOUS arm. Both stop_*_stack functions must also kill by port. | ||
| check "kill_relay_by_port helper is defined" \ | ||
| "$(grep -c '^kill_relay_by_port() {' "$SCRIPT")" "1" | ||
| check "kill_relay_by_port finds its target via ss (by port), not pgrep -f (by name)" \ |
There was a problem hiding this comment.
nit — this check's name promises more than it asserts.
It's named "finds its target via ss (by port), not pgrep -f (by name)", but the assertion is only grep -c 'ss -ltnp' = 1. Adding pgrep -f to the function would leave this check green, so it can't fail in the way its name describes. A second assertion that pgrep is absent from the function body would make the name true.
More generally, all five new checks are structural greps over the script text — consistent with this file's convention, so I'm not asking for behavioral tests. Worth being explicit about the blind spot, though: every one of them passes whether or not the function actually frees the port. Both findings on e11-density.sh in this review (an unregistered ss dependency, and die aborting the EXIT trap) are invisible to all five. A single behavioral check — bind a port with nc -l, call kill_relay_by_port, assert the port is free — would cover the class these can't reach.
There was a problem hiding this comment.
Added a second assertion that pgrep -f is absent from kill_relay_by_port's body, so a regression that reintroduces name-based matching now fails this check. Left the five checks structural per the file's own convention rather than adding the bind/free behavioral check — agreed it's a real blind spot, but that felt like a separate, larger change than this review round; happy to open a follow-up if you'd rather have it now (commit 29adaf5).
| below 1 — nesting adds a roughly constant multiplicative tax to VM-exit-heavy work | ||
| independent of load, not a tax that only shows up under contention. | ||
|
|
||
| **The knee lands at the same c on both substrates: c=8.** That answers the issue's |
There was a problem hiding this comment.
suggestion — this sentence quotes a nested number as a measurement, which this file rules out ~200 lines above.
The existing caveat in this same document is unusually explicit:
A nested run cannot establish the knee's location under real concurrency, an absolute p95, or how close that p95 sits to the container baseline [...] Every number a nested run would produce is a validation result, never a measurement, and must not be quoted as one.
"The knee lands at the same c on both substrates: c=8. That answers the issue's question 3 directly" is the knee's location under real concurrency, from a nested run, presented as an answer. Everything else in this section is scrupulous about this — the opening paragraph states that a nested result fires no stop rule by itself and that the point is the ratio, and the p95 ratio claim is fine (a ratio is not what the caveat forbids, and the container arm hovering near 1x is a good control for box variance). This one sentence is the exception.
The finding itself looks right and is worth keeping — nested's knee landing on the same rung as metal's is real corroboration. It just wants the weaker verb: "nested's knee also lands at c=8, consistent with metal's" is a validation result; "the knee lands at the same c on both substrates … answers question 3" is a measurement.
Smaller point in the same sentence: "answers the issue's question 3 directly" reads oddly against this section's own report that the combined analysis "came back inconclusive on every prediction," prediction 3 being the replenishment-knee one. Both statements can be true (the scorer was sealed against a 7-rung ladder), but a reader hitting them 8 lines apart will want the reconciliation spelled out.
There was a problem hiding this comment.
Fixed — reworded to "nested's knee also lands at c=8, consistent with metal's" (a validation result, not a measurement), and added a sentence reconciling it against the combined analysis's unrelated inconclusive verdict a few lines below: that verdict is a ladder-shape scoring artifact and doesn't bear on this corroboration (commit 29adaf5).
| | resume | 28.58 ms | 78.34 ms | **2.74x** | | ||
| | run | 2.85 ms | 4.12 ms | 1.45x | | ||
| | destroy | 21.31 ms | 118.45 ms | **5.56x** | | ||
| | total | 55.32 ms | 209.72 ms | 3.79x (matches the warm-hot-path ratio above within rounding) | |
There was a problem hiding this comment.
suggestion — the total row is not the sum of the rows above it, and nothing says so.
The sub-costs sum to a different number in both columns:
- metal: 0.00 + 28.58 + 2.85 + 21.31 = 52.74, against a stated total of 55.32
- nested: 0.00 + 78.34 + 4.12 + 118.45 = 200.91, against a stated total of 209.72
Both sums land exactly on that column's "warm hot path p50" from the E10 table above (52.74 / 200.91), and 209.72 is separately identified in the SH_E11_COLD_LATENCY_MS paragraph as "E10 rung 2's warm p50" — so total is evidently a separately measured aggregate rather than the sum, and p50s legitimately don't add. The internal cross-check works on those terms too (209.72/55.32 = 3.79x, matching the 3.81x warm-hot-path ratio as the row claims).
So this is presentation, not arithmetic: a row labelled total inside a table of sub-costs invites the reader to add the column, get a different number, and distrust the table. A parenthetical — total (rung 2 warm p50, measured; p50s do not sum) — settles it, and it's worth naming the ~2.6 ms / ~8.8 ms gap between the two rung-2 metrics while you're there.
One thing worth a glance rather than a change: metal's 55.32 is also metal's container throughput at c=8 in the E11 table below. Almost certainly coincidence, given both columns show the same total-exceeds-sum pattern and 209.72 is independently corroborated — but it's the kind of collision worth confirming against the raw record.
There was a problem hiding this comment.
Fixed — added a parenthetical on the total row plus a sentence naming both gaps (~2.6ms metal, ~8.8ms nested) and confirming the ratio still checks out. Didn't chase the c=8/55.32 coincidence separately since it's corroborated two other ways already (commit 29adaf5).
| #### E10 — full field coverage where a metal baseline exists, nested-only otherwise | ||
|
|
||
| Only the fields EXPERIMENTS.md actually recorded for the metal run (above) have a metal | ||
| side to ratio against; the metal run's raw per-rung JSON was never committed and the box |
There was a problem hiding this comment.
suggestion — this run reproduces the gap this paragraph identifies as the limiter.
The honesty here is good: naming that the metal run's raw per-rung JSON was never committed and the box was later wiped, and marking every field that consequently has no metal side, is more than most write-ups do. But this PR adds 181 lines of nested numbers and no raw data — deploy/microvm/ still holds only predictions.json — and nested-m8i is an EC2 instance that will be wiped exactly as the metal box was. The next ratio study will then hit this paragraph again, verbatim, one substrate later.
Committing the nested per-rung JSON (or, if results are deliberately kept out of the repo — .gitignore does exclude experiments/.results/ — naming where this run's records are archived and under what run id) is what makes the next comparison possible. It also matters for the two places this section already invites re-derivation: the total-vs-sum gap in the rung 2 table, and the prediction scorer's inconclusive verdicts, which can only be re-scored against a ladder shape someone still has.
Not blocking, and not a criticism of the run — the point is only that the fix is cheapest now, while the box is still up.
There was a problem hiding this comment.
Not doing this one. c1946d7 already decided the opposite question for E12's raw per-run rig artifacts: throwaway rig output, not source or a maintained artifact, removed from git and gitignored. I'd be relitigating that same call one experiment later rather than following a genuinely different situation this time. Separately, this run's raw per-rung JSON was never captured in this worktree to begin with — deploy/microvm/ only ever held predictions.json here — so there's nothing on disk to commit even if the policy pointed the other way. If you want a different policy for nested runs specifically (vs. metal/E12), happy to discuss, but I don't think that's mine to decide unilaterally.
…safe teardown, write-up nits cwiklik's review (approved, 7 comments) on the E11 relay-teardown fix and the issue rossoctl#266 ratio write-up: - kill_relay_by_port depends on `ss`, the only use of it in this file, but it was never registered with require_tool. Because the ss call is wrapped in `2>/dev/null`, a missing binary reads back as an empty pid and the function returns "success" without having looked at anything - the exact silently- wrong-data failure this fix exists to prevent, reachable via a missing tool instead of a wrong pid. Added the require_tool line. - kill_relay_by_port's die() can abort cleanup_on_exit's EXIT trap partway through: stop_container_stack/stop_microvm_stack are called from both the trap (best-effort, `|| true`) and the between-arm call sites (must be loud), and die is a bare `exit 1` that the `|| true` cannot catch. Added an E11_IN_CLEANUP flag, set at the top of cleanup_on_exit, so the trap path logs and returns 1 instead of dying, while the between-arm call sites keep the loud die. - Moved kill_relay_by_port's sleep to the top of the loop so the SIGTERM sent by both call sites just before this runs gets a grace window before the first SIGKILL, rather than every teardown escalating straight to SIGKILL and risking a truncated relay log. Swapped grep -oP for sed -n, matching the file's existing non-PCRE grep/awk convention (ss -ltnp is the only other new-to-this-diff external dependency, not grep -P). - e11-density.test.sh's "not pgrep -f (by name)" check only asserted the ss usage, so it stayed green even if pgrep -f were added back. Added a second assertion that pgrep -f is absent from kill_relay_by_port's body, plus one for the new E11_IN_CLEANUP branch. Switched the two ss/die checks from grep -A12 to the file's own sed -n '/^fn() {/,/^}/p' extraction, since the function is now longer than 12 lines. - EXPERIMENTS.md: reworded "the knee lands at the same c on both substrates ... answers the issue's question 3 directly" - this quoted a nested number as a measurement, which the file's own earlier caveat rules out (nested results are validation results, never measurements). Now phrased as corroboration, with a note reconciling it against the combined analysis's unrelated `inconclusive` verdict a few lines below. - EXPERIMENTS.md: the rung-2 decomposition table's `total` row doesn't sum from the four sub-cost rows above it (p50s don't add). Added a note naming the total as a separately measured aggregate and the size of the gap in both columns. Not addressed: the suggestion to commit nested-m8i's raw per-rung JSON before the box is wiped. c1946d7 already decided the opposite for E12 - raw rig output is throwaway, not a maintained artifact - and that data was never captured in this worktree to begin with. Replying on the thread instead of implementing it. Verified: make test-deploy (PASS, all deploy/*/tests suites), pre-commit run --files on the three changed files (PASS: shellcheck, prettier, EOF/trailing whitespace). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
Closes #266.
Repeats the authoritative E10 (
ITERS=200 WARMUP=20) and E11 (SH_E11_ACTIVE_RUNSthrough 32) ladders on
nested-m8i(EC2m8i.xlarge), per the issue's own suggestedfirst cut, and reports a metal/nested ratio for every field that has a metal baseline
on record in
deploy/microvm/EXPERIMENTS.md. Also fixes a real defect ine11-density.shfound while producing this run.Headline findings
opposite direction (0.61x of metal) — so most of the naive 8.04x-vs-1.29x
"ratio of ratios" is inherited from a baseline shift unrelated to nesting. Rung 2's
decomposition isolates the real signal: destroy is taxed harder than resume
(5.56x vs 2.74x).
concurrency level (1.85x–2.60x), while the container arm hovers near 1x as expected.
The knee lands at the same c=8 on both substrates — answering the issue's open
question 3 directly.
docker/grpcurl/pnpm, which it lacked previously).
c=64is deliberately absent from the E11 sweep: 64 concurrent 256MiB VMs need~18GiB against this instance's 15GiB — a genuine memory ceiling this rig hits before
the replenishment ceiling metal hit at the same c.
Bug fix
e11-density.sh's relay teardown between its own two arms killed the wrong process(the pnpm supervisor, not its node child), leaking the container arm's relay and
causing the microvm arm's worker to silently attach to that stale relay instead of its
own. Fixed with a port-based
kill_relay_by_port()helper (mirrorsMETAL-RUNBOOK.md's own manual cleanup recipe), wired into both arms' teardown, with5 new regression checks in
e11-density.test.sh.Test plan
shellcheck -x -S warningclean on both modified shell scriptsdeploy/microvm/tests/e11-density.test.shpasses (0 failures), including the 5new checks pinning the relay-teardown fix
pnpm -C experiments exec vitest run microvm-predictionsstill passes(predictions.json untouched)
nested-m8i, both exit 0🤖 Generated with Claude Code