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 max_connections 150 → 300 in the shared compose file (D7).

#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 doc 0–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 runs docker 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], …) via workspace::cargo_command, which keeps the caller’s NEXTEST_* variables.

    • The pre-push path (phase_devstack_and_tests, profile integration) and CI’s (xtask test --fault-gate, profile ci-integration) share run_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 way docker_probe runs 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 MemTotal alone. 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 with threads: 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=floor and files a fix: issue.

D3 — The override

  • CRAIG_BATTERY_ROW=floor forces the floor; this is the B/A measurement, and a floor run reproduced on a large host. parse_override accepts exactly floor. Any other value (empty, Floor, padded, large, non-UTF-8) is an OverrideError.

  • cargo xtask validate parses it in its preflight, before the repo phases, so a bad value fails in seconds.

  • --skip-devstack and xtask test --fault-gate ignore 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

battery row: floor — docker 4 CPUs / 15.5 GiB, host 4 CPUs → nextest integration threads 8 (profile)

large, U1

battery row: large — docker 32 CPUs / 94.3 GiB, host 32 CPUs → nextest integration threads 8 (profile)

large, U2

battery row: large — docker 32 CPUs / 94.3 GiB, host 32 CPUs; test plane 300 → nextest integration threads 16

demoted, U2

WARNING: the large row needs a dedicated test plane with max_connections >= 300 (<found>), then the floor line naming demoted from large

forced

battery row: floor (forced by CRAIG_BATTERY_ROW; detected large — docker 32 CPUs / 94.3 GiB, host 32 CPUs) → nextest integration threads 8 (profile)

detection failed

the D4 WARNING, then battery row: floor (detection failed) → nextest integration threads 8 (profile); when forced, (forced by CRAIG_BATTERY_ROW; detection failed)

ignored env (any case)

the line ends ; ignored NEXTEST_TEST_THREADS=<v> and/or NEXTEST_RETRIES=<v>

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 passes None; test.rs and .gitlab-ci.yml are unchanged.

  • The argv. fn devstack_nextest_argv(profile: &str, threads: Option<TestThreads>) → Vec<String> appends --test-threads=N last 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 pass None and compare through the same borrow, so the floor’s argv, and with it the step label, stays byte-identical.

  • The environment.

    • cargo_step_with_env gains remove_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 reads Command::get_envs().

    • The contract confirms against cargo nextest run --help that 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. large sets threads: Some(16).

  • postgres-test. max_connections goes from 150 to 300 in docker-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:

    • Fallback when the resolved test-plane URL equals the main instance’s;

    • otherwise SHOW max_connections through the pre-warm’s admin connection gives Dedicated { 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, copy test-results/integration/ and target/validate-phases.log to target/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.xml showing 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: troubleshooting and known-issues get the 16 → 8 → rows history.

  • CHANGELOG: a Changed entry per unit. U2’s ops note: the compose change makes the next dev lifecycle 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 (large with no threads, the env scrub); the D9 docs; Changed

3

U2

THE KNOB: D7; D8 run and recorded (or the no-gain outcome); D10; Changed with the ops note

3

Test matrix

Test Axis Unit Asserts

large_row_needs_sixteen_cpus

sad

U1

15 CPUs → floor, 16 → large

cpus_are_the_smaller_of_host_and_docker

sad

U1

host 32 / docker 8 → floor, and the reverse

large_row_needs_thirty_gib_reported

sad

U1

30 GiB − 1 B → floor; 30 GiB and 31.2 GiB → large

reference_host_selects_large

happy

U1

32 CPUs / 94 GiB → large, with the D5 "large, U1" line verbatim

floor_override_wins_over_a_large_host

happy

U1

the D5 "forced" line verbatim

detection_failure_warns_forced_or_not

fault

U1

the floor, the WARNING and the "detection failed" line, unforced and forced

override_parser_accepts_exactly_floor

evil

U1

proptest: every other string, and non-UTF-8, is a typed error

docker_info_parses_ncpu_and_memtotal

happy

U1

"32 101261819904" → (32, 101261819904)

docker_info_parser_never_panics_and_roundtrips

evil

U1

proptest: arbitrary input is Ok or a typed Err; "{n} {m}" parses back

garbled_docker_info_is_a_parse_error

evil

U1

empty, one field, non-numeric, <no value>, an extra field

rows_ascend_and_the_floor_admits_everything

sad

U1

row 0 is 0 / 0; the minima ascend

large_row_has_no_threads_until_u2

sad

U1

both rows carry threads: None

profile_threads_match_the_integration_profile

sad

U1

PROFILE_THREADS equals nextest.toml’s `[profile.integration] test-threads

battery_command_removes_the_nextest_overrides

evil

U1

the built command’s get_envs() removes both BATTERY_ENV_REMOVALS on both paths

ignored_nextest_env_is_named_on_the_line

sad

U1

the D5 "ignored env" suffix

the_ci_battery_never_selects_a_row

sad

U1

the standalone entry passes None; only the pre-push phase names battery_row

battery_nextest_argv_* (existing, calls borrowed)

happy, sad

U1

the floor argv is byte-identical

large_row_sets_sixteen_and_the_floor_none

sad

U2

replaces large_row_has_no_threads_until_u2

large_row_appends_exactly_one_thread_flag

happy

U2

the large argv is the floor argv plus --test-threads=16

large_row_needs_a_dedicated_300_connection_test_plane

sad

U2

Dedicated{300} keeps large; Dedicated{299}, Fallback and Unreadable demote with the D5 WARNING

test_plane_ceiling_matches_recorded_budget (edited)

happy

U2

postgres-test ≥ 300

Rollout and risks

  • Rollout. U2’s compose edit makes each machine’s next dev lifecycle 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-gate stays at 8. Reproduce a large-row failure with validate, or with cargo 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 battery_row API and test seams; the exact lines and edge rules; a missing U1 pin; where D8 is recorded. Minors folded or filed (#2240, #2241)

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; detect_host and the argv borrow; the untested band qualified. Minors fixed: per-run artifacts, the fingerprint rationale, the 150 in local-dev, the whole-stack rollout, one WARNING rule, the close-out

Edit this page · latest