Repository navigation
fix(e11): set the worker's concurrency slots from the ladder (#305) - #312
Conversation
…l#305) `start_microvm_stack` never set `WORKER_MAX_CONCURRENT`, so the microVM worker kept `session.DefaultConcurrency` = 4. That sizes a FIXED pool of goroutines, one per concurrency slot, per worker process -- so every microVM rung ever recorded measured a 4-slot cap while the ladder swept c to 64, and the surplus c merely queued in front of it. The cap predicts the recorded points rather than merely being consistent with them, which is what makes it the cause: c=1 -> 1/55ms = 18.2 (measured 18.18); c=8 -> 4/62.2ms = 64.3 (67.76); c=16 -> 4/61.4ms = 65.1 (62.99). Lifting it to 16 measured 172.88 Exec/s where the default measured 62.99 on the same host -- 2.74x from one environment variable. - New `worker_max_concurrent_for` resolves the slot count and is a pure function of its argument and the environment, so the suite can drive it. The inline alternative is unreachable by any test, which is how the omission survived. - Defaults to the ladder's largest c, so slots and c move together. `SH_E11_WORKER_MAX_CONCURRENT` overrides it in BOTH directions: Task 1.3 sweeps the slot count against a fixed c, and reproducing the 4-slot cap deliberately is how a lifted one is compared against it on the same box. - An inherited `WORKER_MAX_CONCURRENT` is honoured as the lower-precedence source. That is how the 2.74x was measured before this existed, and since the driver now sets the name explicitly, ignoring an inherited one would silently overwrite the operator's value -- the same defect class as never setting it. - A malformed value REFUSES instead of falling back, because falling back restores the default 4 silently and re-records the artifact from a typo in the one variable that controls it. The refusal names the source it came from. - Below the ladder's largest c it WARNS: those rungs measure queueing against a smaller server, which is exactly how a 4-slot cap came to be published as a density ceiling. Allowed, never silent. - `SH_MAX_RUNS` now covers whichever is larger of the ladder's largest rung and the slot count. Sized from `max_c` alone it could sit below the slot count once the override can exceed it, and a worker with more slots than permitted runs refuses Execs mid-rung -- a refusal that reads as a VM-tier ceiling. - The resolved value and its provenance are logged, so a run's slot count is readable off its own log instead of inferred afterwards. Plan Step 4 (record MaxConcurrent per rung) needed no work: rossoctl#311 already added `maxConcurrent` to the rung record, read back from the worker's own `/stats`. That is strictly better than recording what the driver believes it set, and the existing test for it is left as is. Verified: `bash deploy/microvm/tests/e11-density.test.sh` 0 failures, exit 0 (26 new checks); red-green confirmed by stashing only the driver change, which fails 3 of them. `make lint` exit 0. `pnpm -C experiments exec vitest run microvm-predictions` 3 passed; `predictions.json` untouched. No measurement is published here -- this only makes the next ladder honest. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
mrsabath
left a comment
There was a problem hiding this comment.
Well-argued fix for a genuinely consequential measurement defect. One nit inline, no must-fix.
I verified the causal claims against source rather than accepting the table:
DefaultConcurrency = 4atremote-worker/internal/session/loop.go:41, and its own comment says "the pool size, advertised asHello.capacity_max" — which independently corroborates the reason for deferring the default change to Task 1.2 as a contract change.- It really is a fixed goroutine pool (
loop.go:440,for i := 0; i < s.cfg.MaxConcurrent; i++), so surpluscqueues rather than adding parallelism. The quoted snippet is accurate. - The worker really reads the name being set —
main.go:539-541,envInt64(get, "WORKER_MAX_CONCURRENT", int64(session.DefaultConcurrency)). So the driver's omission genuinely left it at 4. log()writes to stderr (e11-density.sh:337), which is what makes the$(...)capture ofprintf '%s' "$want"safe. That is the load-bearing detail in a helper that both logs and returns a value, and it is right.- Validation holds on every case the doc claims. I exercised it:
0,-1,3.5,abc,8 16, embedded newline, empty, leading/trailing space,1e3,+16all refuse;16,4,1pass. - Early resolution before the
START_STACK=0return is real, so an unusable override is refused on a reuse run too. - The
SH_MAX_RUNSnegative assertion has teeth. I checked the pattern'SH_MAX_RUNS=$((max_c + d + 2))'against the old line — it matches, so the check yieldsyesand fails againstwant=no, while the new code does not match. A properly constructed regression guard, not a tautology. - The
/usr/bin/logshadowing hazard is real and correctly handled. Copyinglog()into the snippet plus requiring thee11:prefix on every assertion is the right fix, and the dedicated non-vacuousness check proves the prefix can only come from the driver's ownlog.
Two small dead-code observations, neither worth an inline comment: ${bad:-<empty>} in the refusal loop never triggers since "" is not in the list (the comment correctly explains empty is deliberately treated as unset and pinned by the two default cases instead); and 007 happens to resolve identically across all three consumers, so only 010-style values expose the finding below.
Stack note: #311 merged at 18:35 and this was opened at 19:38 on top of it, so the e11-density.sh contention flagged when reviewing #311 has resolved cleanly — worker_max_concurrent_for and #311's /stats reader coexist without overlap. The claim that Step 4 needed no work checks out: maxConcurrent is already in the rung record from the worker's own endpoint.
Areas reviewed: Shell (driver + tests), Go (verification of the concurrency claims), security (no secrets, no new deps)
Commits: 1, signed off ✓
CI status: all 13 checks passing
Verdict: APPROVE — 1 nit, no must-fix.
| # larger: a worker with more slots than permitted runs refuses Execs mid-rung, and that | ||
| # refusal reads as a VM-tier density ceiling. The two can now diverge in either direction, | ||
| # because the slot count is independently overridable. | ||
| max_runs=$(((slots > max_c ? slots : max_c) + d + 2)) |
There was a problem hiding this comment.
nit — a leading-zero override makes max_runs disagree with the slot count.
The validation accepts a leading zero (grep -cxE '[0-9]+' matches 010), and [ "010" -lt 1 ] treats it as decimal. But $((...)) here parses 010 as octal 8. So the two consumers disagree:
SH_E11_WORKER_MAX_CONCURRENT=010, max_c=8, d=2
worker receives WORKER_MAX_CONCURRENT=010 -> Go envInt64 parses 10 -> 10 slots
max_runs = $(( (010 > 8 ? 010 : 8) + 2 + 2 )) = 12 # 8 > 8 is false
correct = $(( (10 > 8 ? 10 : 8) + 2 + 2 )) = 14
That lands exactly on the failure this line's own comment exists to prevent — "a worker with more slots than permitted runs refuses Execs mid-rung, and that refusal reads as a VM-tier density ceiling." It is the one input class where the guard silently under-sizes rather than refusing.
Forcing the base in the arithmetic closes it:
max_runs=$(((10#$slots > max_c ? 10#$slots : max_c) + d + 2))or normalising the leading zeros in worker_max_concurrent_for before it returns. Strictly a nit — it requires someone to type a leading zero.
Separately, not worth its own comment: a huge value (99999999999999999999) passes validation and overflows $((...)) to garbage. Unreachable in practice on a slot-count knob, and the worker would fail long before it mattered.
There was a problem hiding this comment.
Fixed in e9a4a60. Reproduced it first: SH_E11_WORKER_MAX_CONCURRENT=010 max_c=8 d=2 gave max_runs=12 where 14 is correct, and confirmed the three-way disagreement — bash's test -lt reads 010 as decimal ([ 010 -eq 10 ] is true), $((010)) is 8, and envInt64 is strconv.ParseInt(v, 10, 64) so the worker got 10 slots.
I took the second of your two options — normalising in worker_max_concurrent_for rather than 10#$slots at the arithmetic — for two reasons. It fixes the single source, so the comment right above that line ("the two can now diverge in either direction") can't invite a second arithmetic use that reintroduces it; and it makes the logged provenance line read worker slots: 10 instead of 010, which otherwise disagrees with the maxConcurrent the rung record reads back from /stats.
On your second observation: it changed how I normalised. want=$((10#$want)) would have closed the leading zero but made the huge-value case worse, not merely unaddressed — $((10#99999999999999999999)) wraps to 7766279631452241919, which is inside int64, so ParseInt would accept it and the worker would try to size a goroutine pool from 7.7e18. Today that value overflows ParseInt and the worker refuses at startup. So the strip is textual (sed 's/^0*//'), which leaves it byte-for-byte unchanged and keeps that refusal. Verified: 99999999999999999999 still returns unchanged, rc=0, same as before this commit.
Placed after the validation, not before, because stripping first turns 000 into the empty string — which this helper deliberately reads as unset, so it would have resolved to the ladder default instead of refusing. There's a check pinning that now, since it's the one way a normalising step could quietly undo the empty-means-unset contract.
Six new checks (520 total, 0 failures, exit 0): the returned value for 010/0010/007, the SH_MAX_RUNS arithmetic it feeds asserted end-to-end (12 is the under-sized answer, 14 the right one), and 000 still refused. Stashing only the driver change fails four of them. make lint exit 0.
worker_max_concurrent_for accepted "010" and returned it verbatim, and its three consumers then disagreed about the base: the validation's `test -lt` and the worker's strconv.ParseInt(v, 10, 64) both read decimal 10, while $((...)) in start_microvm_stack read octal 8. An override of 010 against max_c=8 therefore gave the worker 10 slots and sized SH_MAX_RUNS for 8 -- the one input class where the guard silently under-sizes instead of refusing, and an under-sized MaxRuns makes the worker refuse Execs mid-rung, which is exactly the refusal that reads as a VM-tier density ceiling. Stripped at the single source rather than per-consumer, so a later arithmetic use of the returned value cannot reintroduce it, and textually rather than via $((10#$want)): arithmetic normalisation would also wrap an absurd value into an acceptable one (99999999999999999999 -> 7766279631452241919, which ParseInt takes) where today it overflows ParseInt and the worker refuses at startup. After the validation, so "000" is still refused rather than stripped to the empty string that this helper reads as "unset". Six checks: the returned value for 010/0010/007, the SH_MAX_RUNS arithmetic it feeds (12 was the under-sized answer, 14 is right), and "000" still refused. Stashing only the driver change fails four of them. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… model fit and three ratios All ten findings from @huang195, @mrsabath and @aslom were checked against `main` and all were correct. The cold-rate finding resolves better than the reviews assumed. Both tables already used `coldAcquireRateTrue`, diffed from the worker's vmpool.Stats counters, not the `coldAcquireRate` latency proxy #306 discredits. The records show why that matters: across these rungs the proxy reads a saturated 1.000 everywhere, carrying no information, while the true metric tracks the ladder 0.142 -> 0.698. Now labelled, and #306 reconciled rather than hedged: its ">99% warm at c=16, the restore was never on the hot path" was measured under the 4-slot cap where demand was four slots' worth. Past 64 slots demand outruns replenishment and the true cold rate reaches 0.698, so the restore is on the hot path in this regime and was not in that one. Both readings are right about their own configuration. The "each then paying a full restore" phrasing is replaced with the measured share, and the note now says the argument stands on `Acquire` growing 65x regardless of how coldness is counted. Corrected arithmetic: - "within ~4%" was wrong and wrong at the peak: the model over-predicts by 6.4% at 64 slots, 4.2% at 128, 2.9% at 256. Stated with the table. - Two per-Exec totals were in use without the difference being named. The column is summed instrumented sub-phases (104.11 ms); wall-clock per slot is slots/throughput (110.81 ms). The 2.8-6.0% residual is uninstrumented time, and by this document's own rule about unexplained zeros it is now flagged as a lower bound rather than passed over. Resume+Destroy is given against both denominators: 90.0% of summed, 84.6% of wall-clock. - "roughly 90x" on memory did not follow from any figure present. Replaced with the divisions shown: 144x worst observed VM, 320x mean, 58x budget against host memory used. 144x is the one to quote. - The gains table explained its own non-composition with "each was measured against the tree that preceded it", which is the reason they *would* compose. Real cause named: each was measured at the slot count and configuration current when it landed. Composed they give 56x against an actual 9.2x. - 577.55 and 580.60 are now labelled as separate sessions, with the 0.5% spread placed inside the measured 2.9% drift. Also: the tier's shipped default is 16 (rossoctl#313), deliberately 4x below the measured peak, and reaching 64 needs WORKER_MAX_CONCURRENT set — the capacity section said "raised" without saying from what. The self-describing rung record is rossoctl#312's work; rossoctl#313 never touched the driver. `session.MaxConcurrent` is not a symbol; the constant is `session.DefaultConcurrency = 4`. In the dead-ends note: `microvm-worker` does have a pprof endpoint on `main` since rossoctl#308, so the "it had none" lesson is marked as acted on rather than left to be re-added; and the pointer into EXPERIMENTS.md section E11 now directs readers to rossoctl#305 and PR rossoctl#300, since the section still carries the pre-correction banner until rossoctl#300 merges. Refs rossoctl#305 #306 rossoctl#308 rossoctl#312 rossoctl#313 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Part of #305. Task 1.1 of the Exec/s throughput campaign: the gate that has to land before
the 2.74x can be measured without measuring the cap again.
The defect
start_microvm_stacknever setWORKER_MAX_CONCURRENT, so the microVM worker keptsession.DefaultConcurrency= 4. That value sizes a fixed pool of goroutines, one perconcurrency slot, per worker process:
So every microVM rung ever recorded measured a 4-slot cap while the ladder swept
cto 64.The surplus
cqueued in front of it.The cap predicts the recorded points rather than merely being consistent with them, which
is what makes it the cause and not a candidate:
What this PR does
Adds
worker_max_concurrent_forand passes its result to the worker. It is a pure function ofits argument and the environment, so the suite can drive it — the inline alternative is
unreachable by any test, which is how the omission survived in the first place (the same
reasoning the file already records for
exec_error_note_for).ccmove together; no rung measures the queue in front of a smaller serverSH_E11_WORKER_MAX_CONCURRENToverrides, both directionsc, and reproducing the 4-slot cap deliberately is how a lifted one is compared on the same boxWORKER_MAX_CONCURRENTis honoured, at lower precedencecSH_MAX_RUNScoversmax(slots, max_c)max_calone it can sit below the slot count once the override may exceed it, and a worker with more slots than permitted runs refuses Execs mid-rung — a refusal that reads as a VM-tier ceilingStep 4 needed no work
The plan's Step 4 was "record
MaxConcurrentper rung". #311 already did it —maxConcurrentis in the rung record, read back from the worker's own/statsendpoint. Thatis strictly better than recording what the driver believes it set, since it cannot disagree
with the slot count actually in force. Its existing test is left untouched.
Verification
bash deploy/microvm/tests/e11-density.test.shmake lint(shellcheck + prettier)pnpm -C experiments exec vitest run microvm-predictionspredictions.jsonuntouchedTwo of the new checks are guards against the tests themselves passing vacuously:
logis a one-liner thatextract_fncannot delimit, so it is copied into thesnippet the way
diealready is. Without it the helper's warning reached/usr/bin/logon macOS, whose
Unknown subcommand '...'usage text echoes the argument back and sosatisfied a naive match on the warning's own words. Every assertion now requires the
e11:prefix, and one check proves that prefix can only come from the driver's own
log.SH_E11_*knob.Not in this PR
session.DefaultConcurrency). Raising it changesHello.capacity_max— what the relay is told it may dispatch — which is a contract changeand a human call. That is Task 1.2.
🤖 Generated with Claude Code