Plan: Battery Host Rows (#1977 Part B)
Archive record
!1855 (U0 plan page, the epic, the unit and follow-up issues, Relates #1977) + !1856 (U1, Closes #2242) + !1857 (U2,
Closes #2243 and #1977) — 2026-10-09: approved in plan mode on 2026-10-09 after a contextless round 1 (no-ship, 7 blockers
fixed) and the maintainer’s round 2 (no-ship, 6 findings fixed). What landed: the host row (U1: xtask/src/battery_row.rs
reads the Docker engine’s CPUs and memory, selects floor (the ruled 4-core / 16 GB minimum, today’s settings) or large
(at least 16 CPUs and 30 GiB reported) and prints the row immediately before the battery’s nextest step;
CRAIG_BATTERY_ROW=floor forces the floor and is parsed at validate’s preflight; a detection failure runs the floor with a
WARNING; the battery’s nextest command removes NEXTEST_TEST_THREADS and NEXTEST_RETRIES; CI selects no row). U2
measured 16 threads on large (D8): 31 % faster in the paired run, but two of three 16-thread runs redded in
craig-exchange’s outbound_triggers suite, so no row sets a thread count and postgres-test stays at 150; the design for
the gated knob is D7. B1 (Playwright workers) was split out and B3 (tail overlap) dropped. Follow-ups: #2244 (the
16-thread instability and a re-measure), #2238 (B1), #2239 (the perf-smoke fence’s 90 s wait), #2240 (the stale hook
docs), #2241 (a silently skipping budget pin).
Status
Done (2026-10-09) — !1857; B2 measured faster but unstable, no thread change
| Anchor | What binds here |
|---|---|
#1977 B0 (ruled 2026-10-06) |
Minimum developer machine 4 cores / 16 GB. At the floor every battery setting stays as today; larger hosts may run harder, never hotter than their own resources. The chosen row is printed at battery start. |
Re-scope (ruled 2026-10-09) |
B1 (Playwright workers) is its own plan issue (#2238); B3 (tail overlap) is dropped. |
Ceiling (approved with this plan, 2026-10-09) |
postgres-test |
#1347; standing rules |
Serial image builds hold the memory floor. No timeout is touched. CI profiles keep their values. |
Context (census 2026-10-09, on main)
-
Where the time goes. Six batteries took 996–1,858 s in total:
-
nextest ≈ 360 s every time;
-
e2e ≈ 420 s;
-
perf smoke 97 s;
-
SDK 11–15 s;
-
security regression and
cargo doc0–1 s each.
-
-
Threads. All four nextest profiles set
test-threads = 8(.config/nextest.toml). 16 ran from 2026-03-09 to 2026-03-22 and was cut back for pre-push timeouts. That was before #1160, #1162, #1163, #1275, #1403 and the twelve serial test groups. -
The battery today:
-
Nothing in xtask reads the host’s CPUs or memory;
docker_probe(xtask/src/cmd/validate.rs) already runsdocker info. -
The battery argv is a fixed
[&str; 7](devstack_nextest_argv), and two tests pin it. -
It spawns through
cargo_step_with_env(&[&str], …)viaworkspace::cargo_command, which keeps the caller’sNEXTEST_*variables. -
The pre-push path (
phase_devstack_and_tests, profileintegration) and CI’s (xtask test --fault-gate, profileci-integration) sharerun_devstack_battery.
-
-
Capacity at 16 threads:
-
postgres-test binds. Each running test holds a pool of about 10 connections on its scratch clone, so 16 threads need about 160, over the 150 ceiling.
-
Main Postgres: 250, worst case about 158.
-
Service pools: 10 each with a 5 s acquire; the residual risk, and no timeout is touched.
-
Fault proxy ports (64): at most 16 leases.
-
Test-plane fallback: when postgres-test is unresolved, the scratch DBs fall back to the main instance (
craig-test-lib).
-
Scope
In: B0 (D1–D6), B2 (D7, D8), the D9 docs, the D10 close-out.
Out:
-
B1 (#2238);
-
B3 (dropped);
-
the perf-fence defect (#2239);
-
the stale hook docs (#2240);
-
the silent-skip budget pin (#2241);
-
the CI profiles' values;
-
every timeout;
-
service pool sizes;
-
compose resource limits;
-
hybrid-core weighting.
Design
D1 — The signal
-
Source.
docker info --format '{{.NCPU}} {{.MemTotal}}', run the waydocker_proberuns it. This is the Docker engine’s view: the host on Linux, the VM on Docker Desktop, which is what the devstack gets. -
CPUs. The smaller of that NCPU and
std::thread::available_parallelism(). -
Memory. Docker’s
MemTotalalone. On Linux it is the host figure. On Desktop the VM is carved out of host RAM. -
Dependencies. None new.
D2 — xtask/src/battery_row.rs (new)
pub(crate) struct Cpus(u32); // logical CPUs
pub(crate) struct MemBytes(u64);
pub(crate) struct TestThreads(NonZeroU16); // nextest_flag() -> "--test-threads=N"
pub(crate) enum RowName { Floor, Large }
pub(crate) struct BatteryRow { name: RowName, min_cpus: Cpus, min_mem: MemBytes, threads: Option<TestThreads> }
pub(crate) const ROWS: [BatteryRow; 2]; // ascending: floor 0 / 0; large 16 CPUs / 30 GiB
pub(crate) const PROFILE_THREADS: u16 = 8; // printed; pinned to nextest.toml [profile.integration]
pub(crate) const TEST_PLANE_CEILING: u32 = 300; // U2: the large row's required test-plane max_connections
pub(crate) struct Host { docker_cpus: Cpus, docker_mem: MemBytes, host_cpus: Cpus }
pub(crate) enum TestPlane { Dedicated { ceiling: u32 }, Fallback, Unreadable(String) }
#[derive(thiserror::Error)] pub(crate) enum OverrideError { Unknown(String), NotUnicode }
#[derive(thiserror::Error)] pub(crate) enum DetectError { HostCpus(String), DockerSpawn(String), DockerExit(String), Parse(String) }
pub(crate) struct Selection { /* row, forced, detection, demotion, ignored env */ } // test_threads(), lines()
pub(crate) fn parse_override(raw: Option<&OsStr>) -> Result<Option<RowName>, OverrideError>;
pub(crate) fn parse_docker_info(stdout: &str) -> Result<(Cpus, MemBytes), DetectError>;
pub(crate) fn select(forced: Option<RowName>, detected: Result<Host, DetectError>) -> Selection;
pub(crate) fn gate_on_test_plane(selection: Selection, plane: TestPlane) -> Selection; // U2
pub(crate) fn detect_host() -> Result<Host, DetectError>; // the only fn that reads the host or runs docker
-
Test seams. Tests drive the pure functions; none shells out or sets the environment.
-
large’s minima.At least 16 CPUs AND at least 30 GiB reported. A "32 GB" machine reports about 31.2 GiB. Selection takes the last row whose minima the host meets. U1 ships `large withthreads: None. -
Operating range. D8 validates the reference host (32 CPUs / 94 GiB). The 16–31 CPU, 30–90 GiB band is enabled by proportionality, not by a run: per CPU and per GiB it carries no more test processes than the floor’s 8 on 4 cores and 16 GB. D9 says so; a host there that reds runs with
CRAIG_BATTERY_ROW=floorand files afix:issue.
D3 — The override
-
CRAIG_BATTERY_ROW=floorforces the floor; this is the B/A measurement, and a floor run reproduced on a large host.parse_overrideaccepts exactlyfloor. Any other value (empty,Floor, padded,large, non-UTF-8) is anOverrideError. -
cargo xtask validateparses it in its preflight, before the repo phases, so a bad value fails in seconds. -
--skip-devstackandxtask test --fault-gateignore it (D9).
D4 — Detection failure
If available_parallelism() errors, or docker info fails or prints something unparseable (a Podman shim prints
<no value>), the battery runs the floor. Whether or not the floor was forced, it prints
WARNING: host detection failed: <cause>.
D5 — The lines
Printed to stdout and written to validate’s journal once, immediately before the nextest step (after the template pre-warm),
with no step marker. U1’s docker info probe counts toward the segment open when phase_devstack_and_tests selects the
row (after ensure_ready); in U2 the ceiling read counts toward the pre-warm segment. Erratum (2026-10-09, U1 #2242):
D6’s parameter is the row selection itself, Option<&Selection>, so the battery body prints D5’s lines immediately
before nextest and U2 gates the same selection after the pre-warm; detection moved out of the pre-warm segment.
GiB prints with one decimal, from integer tenths.
| Case | Line(s) |
|---|---|
floor |
|
large, U1 |
|
large, U2 |
|
demoted, U2 |
|
forced |
|
detection failed |
the D4 WARNING, then |
ignored env (any case) |
the line ends |
D6 — Threading and the nextest environment
-
Who selects. Only the pre-push path selects a row, with
run_devstack_battery(profile: &str, row: Option<&Selection>, steps: &mut StepCounter). The CI standalone entry passesNone;test.rsand.gitlab-ci.ymlare unchanged. -
The argv.
fn devstack_nextest_argv(profile: &str, threads: Option<TestThreads>) → Vec<String>appends--test-threads=Nlast when a row sets it. The call site borrows it:let refs: Vec<&str> = argv.iter().map(String::as_str).collect();. The two existing argv tests passNoneand compare through the same borrow, so the floor’s argv, and with it the step label, stays byte-identical. -
The environment.
-
cargo_step_with_envgainsremove_env: &[&str]; its other callers pass&[]. -
The battery passes
BATTERY_ENV_REMOVALS = ["NEXTEST_TEST_THREADS", "NEXTEST_RETRIES"]on both paths. CI sets neither, which the contract verifies, so CI’s behaviour is unchanged. -
The spawn goes through a pure builder,
fn cargo_command_for(args, env, remove_env) → Command, so a test readsCommand::get_envs(). -
The contract confirms against
cargo nextest run --helpthat no other variable sets the thread count or retries.
-
-
Comments U1 makes false. These are reworded:
run_devstack_battery’s "they differ only in `profile`", the argv doc’s "only the profile varies by caller", and the doc of `battery_nextest_argv_varies_only_the_profile.
D7 — U2: the knob, its ceiling, its gate
-
Threads.
largesetsthreads: Some(16). -
postgres-test.
max_connectionsgoes from 150 to 300 indocker-compose.yml, with a budget comment: 150 was 8 × 10 plus the pre-warm plus headroom (≈ 18.75 per thread), and the same allowance at 16 is 300.-
A ceiling, not demand. The floor and CI still open about 80.
-
Cost. About 6–7 MB more shared memory.
-
-
The run-time gate. After the template pre-warm, the pre-push battery classifies the test plane as a
TestPlane:-
Fallbackwhen the resolved test-plane URL equals the main instance’s; -
otherwise
SHOW max_connectionsthrough the pre-warm’s admin connection givesDedicated { ceiling }; -
a failed read gives
Unreadable.`gate_on_test_plane` keeps `large` only for `Dedicated { ceiling >= 300 }`; anything else is the floor plus the D5 WARNING. So every large-row run carries affirmative evidence, the ceiling on its line. The pin `test_plane_ceiling_matches_recorded_budget` rises to ≥ 300; its skips are #2241. * *Main instance.* It keeps 250; its budget comment is re-derived for both rows. * *Comments.* Only present-tense ones change: `fault/port_lease.rs` ("up to sixteen workers, one lease each") and the `integration` profile in `nextest.toml` ("the floor row; validate overrides on the large row").
-
D8 — U2 acceptance (before its push; recorded in the U2 MR description)
-
Per run. Each run is
cargo xtask validate --skip-docker. Before the next run starts, copytest-results/integration/andtarget/validate-phases.logtotarget/1977b/run-<n>/. -
Stability. Three consecutive large-row runs, each with:
-
validate exit 0;
-
the row line showing
large … test plane 300 → … threads 16; -
the run’s junit
test-results/integration/integration/results.xmlshowing every test passed, none timed out and none retried.Intentional fault tests (for example `pool_contention`'s asserted `PoolTimedOut`) pass as tests, and that is all the gate reads. Any failure, timeout or retry resets the count. * *A large-row-only red is a defect.* Fix it with test-group membership in all three profiles (`integration` and `ci-integration` are parity-pinned; `default` is kept by hand) or with owned fixtures. Never retry, never widen a bound. * *Performance.* Two B/A pairs, each: reseed, a floor run (`CRAIG_BATTERY_ROW=floor`), reseed, a large run. U2 ships the thread change only if, in both pairs, the large run's nextest step (validate's timing table) is at least 20 % shorter than its paired floor run, and its validate total is no longer. * *If either criterion fails,* U2 ships only the measurement record and the docs. `large` keeps `threads: None`, and postgres-test stays at 150. The plan closes as B2 measured, no gain. * *Per-test timing.* A test above half its kill bound in any large run gets its own `test:` issue.
-
D9 — Docs
-
local-dev:-
a hardware line in Prerequisites (the floor);
-
§ Battery host rows: the table, the lines, the override and where it is ignored, the operating-range qualification, and that a Desktop VM’s allocation decides the row;
-
in U2, its 150-connection statement becomes 300.
-
-
testing-reference: the nextest profile note gains the large row. -
Stale "16 configured" text:
troubleshootingandknown-issuesget the 16 → 8 → rows history. -
CHANGELOG: aChangedentry per unit. U2’s ops note: the compose change makes the nextdevlifecycle tear down and recreate the whole devstack, which ends open sessions; no reseed is needed.
D10 — Close-out (U2)
-
Status:
Done (<date>) — !<U2>and the archive move with its row, before the merge. -
Pre-merge:
plan-lint --done docs/modules/ROOT/pages/plans/archive/battery-host-rows.adoc --allow-open 1977 --allow-open 2238 --allow-open 2239 --allow-open 2240 --allow-open 2241. -
Post-merge: the same command on
main, without--allow-open 1977, recorded in the closing note.
Erratum (2026-10-09, U2): D10’s two plan-lint runs also pass --allow-missing for the three gitignored D8 artifacts this page cites (target/validate-phases.log, test-results/integration/, test-results/integration/integration/results.xml), which are never tracked. D8’s outcome: 16 threads cut the nextest step by 31 % against its paired floor run, but two of three 16-thread runs redded in craig-exchange’s outbound_triggers suite (diagnosed from source as craig-cases pool saturation feeding exchange’s 5 s / 30 s trigger retry ladder past the suite’s 45 s settle window), which no allowed large-row fix reaches; U2 shipped the record and the docs only, and large keeps no thread count.
Erratum (2026-10-11, #2244): the thread pursuit closed won’t-do. The local-read retry shipped and stays, but the 16-thread re-measure still redded outbound_triggers on the global CPRS partner slot, so U1’s thread plumbing is removed: the TestThreads newtype, the BatteryRow threads field, Selection::test_threads and the argv’s threads slot. Every row runs the profile’s 8, and the row line is byte-identical.
Units
U1 relates to #1977. U2 closes it: Part A has landed, B0 and B2 are this plan, B1 is split and B3 is dropped.
| MR | Scope | W |
|---|---|---|
U0 |
this page (Active nav); the epic, U1 and U2; issues #2238, #2239, #2240, #2241; the re-scope on #1977 |
1 |
U1 |
DETECT AND PRINT: D1–D6 ( |
3 |
U2 |
THE KNOB: D7; D8 run and recorded (or the no-gain outcome); D10; |
3 |
Test matrix
| Test | Axis | Unit | Asserts |
|---|---|---|---|
|
sad |
U1 |
15 CPUs → floor, 16 → large |
|
sad |
U1 |
host 32 / docker 8 → floor, and the reverse |
|
sad |
U1 |
30 GiB − 1 B → floor; 30 GiB and 31.2 GiB → large |
|
happy |
U1 |
32 CPUs / 94 GiB → large, with the D5 "large, U1" line verbatim |
|
happy |
U1 |
the D5 "forced" line verbatim |
|
fault |
U1 |
the floor, the WARNING and the "detection failed" line, unforced and forced |
|
evil |
U1 |
proptest: every other string, and non-UTF-8, is a typed error |
|
happy |
U1 |
|
|
evil |
U1 |
proptest: arbitrary input is |
|
evil |
U1 |
empty, one field, non-numeric, |
|
sad |
U1 |
row 0 is 0 / 0; the minima ascend |
|
sad |
U1 |
both rows carry |
|
sad |
U1 |
|
|
evil |
U1 |
the built command’s |
|
sad |
U1 |
the D5 "ignored env" suffix |
|
sad |
U1 |
the standalone entry passes |
|
happy, sad |
U1 |
the floor argv is byte-identical |
|
sad |
U2 |
replaces |
|
happy |
U2 |
the large argv is the floor argv plus |
|
sad |
U2 |
|
|
happy |
U2 |
postgres-test ≥ 300 |
Rollout and risks
-
Rollout. U2’s compose edit makes each machine’s next
devlifecycle tear down and recreate the whole devstack (the guard’s compose drift), which ends open sessions. The templates re-warm themselves, and no reseed is needed. -
Risks:
-
Concurrent test pairs grow about fourfold (28 → 120). D8 is the gate.
-
Service pools of 10 are the residual cliff.
-
xtask test --fault-gatestays at 8. Reproduce a large-row failure withvalidate, or withcargo nextest run --workspace --locked --profile integration --run-ignored=all --test-threads=16. -
Efficiency cores count as full CPUs (escape hatch:
CRAIG_BATTERY_ROW=floor). -
The 16–31 CPU band is not directly validated (D2).
-
Review log
| Round | Vendor | Resolved model | Verdict |
|---|---|---|---|
1 |
Anthropic — one fresh contextless reviewer (the page, the rules, the four questions) |
Claude Opus 5.5 |
no-ship — 7
blockers fixed: the MR number in the body; the docker-info proptest; the argv signature; the |
2 |
maintainer-run on another vendor’s model (2026-10-09) |
OpenAI GPT Astra |
no-ship — 6 findings fixed: the nextest env
precedence (scrubbed, reported); a run-time test-plane gate in place of a skippable pin; outcome-based acceptance from junit; a
≥ 20 % performance criterion with a no-gain outcome; |