| 1 | # CI speed and flakes (branch ci-speed) |
| 2 | |
| 3 | CI runs on docs-t1, a shared box at load 25 to 40. Amadan's cloud runner |
| 4 | is off the table for now (arm64, bwrap 0.9, no writable user cgroup; |
| 5 | Equipo pins x86 codex and bwrap 0.11), so this branch makes the shared |
| 6 | runner path as calm as it can be. |
| 7 | |
| 8 | ## What changed |
| 9 | |
| 10 | - **Test cache on.** `make test` no longer passes `-count=1`. A package |
| 11 | whose test binary, declared inputs and environment are unchanged |
| 12 | replays its pass, so a rerun after one failure runs only what failed. |
| 13 | The amadan runner keeps a per-repo `GOCACHE` between jobs and reuses a |
| 14 | branch's worktree (`git checkout --force`), so unchanged files keep |
| 15 | their modification times and the cache holds across pushes. |
| 16 | - **Hidden inputs declared** (`internal/testci`). go test's cache sees |
| 17 | only what the test process opens and the environment it reads, so: |
| 18 | - `testci.GoCommand` / `GoPackages`: a child `go build`, `go test -c` |
| 19 | or `go list` of repo packages declares their source (cmd/equipo, |
| 20 | the runner and tool proxy builds, directlive's fake driver, the |
| 21 | try-equipo chain, the runnerproto boundary check). |
| 22 | - `testci.Files`: scripts and fixtures a child runs (no-fake-worker, |
| 23 | live-gate, install manifest, plan3 copy check, release check). |
| 24 | - `testci.RepoFiles`: the dead-reference scan and the release tree copy |
| 25 | read every file git lists. |
| 26 | - `testci.Tools`: codex, claude, bwrap, git, python3, sh, srt, tar and |
| 27 | the pinned try binaries; `scripts/ci-test.py` fingerprints them into |
| 28 | `EQUIPO_TEST_TOOLS`, so upgrading one reruns its tests. |
| 29 | - Still uncached: the perf lane (a measurement), and the separate |
| 30 | `runner-adapter-test`, `runner-namespace-test` and `migration-check` |
| 31 | targets. `UNCACHED` in `scripts/ci-test.py` is empty. |
| 32 | - **Slow packages split into lanes.** Measured from CI receipts on |
| 33 | 092d8ce, 62aa30c and four other branches: headless 6 to 10 min, |
| 34 | equipotest 2.2 to 3.4, runner 1.6 to 3, directlive 1.4 to 2.9, |
| 35 | thintest about 1, runner/checks 0.6 to 1, runner/thin 0.5. Lanes: |
| 36 | headless, thintest, directlive, runner-thin, runner, contracts |
| 37 | (equipotest, plan3test), rest. amadan runs separate ci.d steps one |
| 38 | after another, so seven steps would add their times (about 15 min); |
| 39 | its parallel mechanism is a step's `@N` shards, so the lanes are the |
| 40 | seven shards of `30-test@7`, each with its own log and verdict, and |
| 41 | `make test-lane LANE=x` runs one locally. |
| 42 | - **Cache keys stay stable across jobs.** The amadan runner moves the |
| 43 | worktree root's modification time at the start of every job, and go |
| 44 | test records the directory a child process starts in, so any test that |
| 45 | started a child in the root missed the cache every time (directlive, |
| 46 | equipotest, release, tryequipo). Those children now start in the test's |
| 47 | own package directory, and each lane prints a `cache miss:` line per |
| 48 | package that ran, so a new miss is visible in the log. |
| 49 | - **Timing budgets report on shared runners.** Time budgets fail the |
| 50 | step only where `EQUIPO_CI_DEDICATED=1` is in the runner's environment |
| 51 | (for a dedicated x86 box later; amadan passes the runner's own |
| 52 | environment through, and has no runner tags in the step env). Size |
| 53 | budgets stay enforced by `make budget` everywhere. |
| 54 | |
| 55 | ## Known flakes |
| 56 | |
| 57 | Fixed: |
| 58 | - **tryequipo `provider_account_busy`**: `openAccount` closed the home's |
| 59 | lock descriptor on its error paths without unlocking it. A child |
| 60 | forked at that moment (parallel tests fork constantly) keeps the |
| 61 | descriptor, and the lock, until it execs, so the wizard's immediate |
| 62 | re-lock found the home busy. It now unlocks before closing, as |
| 63 | `Close` already did. |
| 64 | - **tryequipo "text file busy"**: a test-written fake program (and |
| 65 | `pinExecutable`'s copy) was open for writing while another goroutine |
| 66 | forked; the child held it open and exec failed with ETXTBSY. Writes of |
| 67 | programs now hold `syscall.ForkLock` until the file is closed |
| 68 | (tryequipo and directlive tests, `pinExecutable`). |
| 69 | - **transfer contract timeouts** (thintest): the fake runner waited 10 s |
| 70 | per frame, and the rig 30 s per contract. At load 78 locally, |
| 71 | `TestContractWorkerTaintIsSticky` hit the same "waiting for send_pack: |
| 72 | context deadline exceeded" as CI. Now 45 s per frame, 2 min per |
| 73 | contract. |
| 74 | |
| 75 | Quarantined (`scripts/ci-quarantine.txt`, step `test-quarantine`, one |
| 76 | automatic retry, a pass on the retry printed as `FLAKE`): |
| 77 | - TestMixedVersions (headless M8). Its first run in this step failed |
| 78 | locally and passed on the retry: sampleToReady saw ready to merge, then |
| 79 | re-read the task as `merging` and called that not ready. Fixed (merging |
| 80 | is accepted); it stays here until a clean week shows that was the only |
| 81 | cause. |
| 82 | - TestHeadlessConnections A5, C4 and the seven C5 scenarios. C4's fake |
| 83 | sign-in callback got EOF at load 78 locally; cause not found yet. |
| 84 | - TestRunnerCancelAndSupersede (runner/thin): the runner closed the |
| 85 | stream after acking; cc6567a logs why, so the next failure names it. |
| 86 | - TestCheckSandboxDeniedPathsTampering (runner/checks): "child survived |
| 87 | cancellation". Cancelling at 1 to 60 ms after start left no survivor |
| 88 | in 50 local runs at load 50 to 78, so it is not the start-up window. |
| 89 | |
| 90 | Not addressed: |
| 91 | - **directlive `provider_account_containment`**: no failing CI log names |
| 92 | the test, and containment has some twenty sources. Not quarantined |
| 93 | blind; the openAccount unlock fix may cover it if it was a lingering |
| 94 | lock. Quarantine it by name once a log shows it. |
| 95 | |
| 96 | ## Timings (docs-t1 CI, whole job, sum of steps) |
| 97 | |
| 98 | Before (thin-v1-darwin 092d8ce, `-count=1`, load 25 to 40): 524 s, test |
| 99 | step 450 s (headless alone 7m28s). thin-v1-claudetoken: test step 600 s. |
| 100 | Every run paid this: a rerun after a flake, a docs edit, a one-package |
| 101 | change. |
| 102 | |
| 103 | After (ci-speed, box load about 3 to 10 this evening, so not like for |
| 104 | like): |
| 105 | |
| 106 | | run | job | test step | quarantine step | |
| 107 | |---|---|---|---| |
| 108 | | first run of the branch, nothing cached (5a1890a) | 511 s | 313 s (headless lane) | 114 s | |
| 109 | | rerun, nothing changed (d747ee8) | 67 s | 13 s | 7 s | |
| 110 | | one package changed, internal/tryequipo (88f8111) | 218 s | 165 s | 8 s | |
| 111 | | testci changed, imported by most heavy packages (d747ee8) | 436 s | 286 s | 92 s | |
| 112 | |
| 113 | A one-package change reruns that package, its importers, and |
| 114 | equipotest: its release and dead-reference tests read the whole tree |
| 115 | (testci.RepoFiles), so it reruns on any commit (about 2.5 min). |
| 116 | |
| 117 | Needs a dedicated runner: strict per-package time budgets |
| 118 | (`EQUIPO_CI_DEDICATED=1` in the runner's environment). runner/thin |
| 119 | measured 52 to 74 s locally against its 45 s record, reported only here. |
| 120 | |