gunk-dev/the-valley
the-valley:bd-6fafd54bugclosed

valley pending spends half its time in the main phase when nothing is ready

State
done
Created
2026-11-13 by contributor
Changes
  • valley:the-valley/nwuwoqpzqnopyvxusoxurwwwpyuslpuk

Body

With no ready change, `valley pending` in a project of about 600 versions takes 3.2 s, and half of it is the `main` phase. Command records from two runs at 1ca8baa:

| phase     | ms   | processes |
|-----------|------|-----------|
| main      | 1605–1632 | 26   |
| changes   | 383–430   | 173  |
| fetch     | 377–402   | 10   |
| transfers | 291–302   | 14   |
| policy    | 247–264   | 4    |
| knots     | 149–162   | 3    |
| other, records | about 40 | 14 |

The `main` phase (`mainState`, `status/pending.go`) covers two things the phase clock does not tell apart:

- the follow walk (`mainFollows`, `status/mainstate.go`): one coverage judgement and tree digest per first-parent commit until every follow check's pass is found. Here the walk was two commits long.
- the wait for the worker telemetry read (`costs.start`, `readBuilds` in `status/checkcost.go`): a paged read over ssh, up to `costRecords` records. One page read on its own (`valley telemetry read --source worker`) took 0.5 s where a bare ssh round trip took 0.1 s.

First step: give the telemetry wait its own phase, so a command record says which of the two the time goes to. Then, depending on the answer:

- if it is the telemetry read: start it before the other phases so it overlaps them, and read no more pages than main's line needs when `--checks` is not given;
- if it is the walk: remember each commit's tree digest and coverage in the client cache, as landings remember transfers.

The `changes` phase starts 173 processes for 0.4 s; that count grows with the number of versions and is the next thing to look at after `main`.

Comments

  1. contributor2026-11-15 15:24 UTC
    Independent review of 7148dc1 (run 20261115-1431-3d35bb2b, 48 min, $11.46; 13 files +426/-86; nothing-ready warm 3.3 s to 1.6 s, 265 to 73 processes; output identical old against new). NOT READY: one blocker, the early telemetry read is neither cancelled nor joined on return and can leave an ssh child holding an observe slot. No trust or reachability finding. Fix round launched. Remaining to reach under a second: eight sequential network round trips of about 125 ms; follow-up to run the independent ones side by side.
  2. contributor2026-11-15 15:56 UTC
    Recheck of 1ae5b76 (run 20261115-1524-0acff070, 28 min, $16.65 cumulative): ordinary returns closed; the added signal handler can swallow a signal or change the exit status, and SIGPIPE, a signal to the check line alone and the review walk's first read are uncovered. Second fix round launched with a simpler shape: no signal handler; the ssh child dies with its parent at the OS level, as builds already do.
  3. contributor2026-11-15 16:34 UTC
    Final recheck of fa3a154 (run 20261115-1556-595488f2, 33 min, $22.46 cumulative): parent-death approach sound for all callers, exit statuses match main. Three small items sent back: stderr capture unbounded; ssh config ForkAfterAuthentication can escape the lifetime control; the non-Linux bound is overstated in the docs.
  4. contributor2026-11-15 16:56 UTC
    Last round (run 20261115-1634-0348f582, 21 min, $25.93 cumulative; 5 files +96/-19): ssh's stderr bounded to its last 4 KiB through a pipe the read owns; ForkAfterAuthentication=no (needs OpenSSH 8.7); non-Linux bound stated as it is. Coordinator read the code and marked 1abd59f ready. Whole change: 21 files +888/-109; three independent passes. Nothing-ready warm: 3.3 s to about 1.6 s. Measured with two changes ready: installed client 5.7 to 6.0 s, this change about 4.2 to 4.5 s (agent's figure). The ready case is the one the operator lives in and is the next target.
  5. contributor2026-11-15 20:49 UTC
    Change valley:the-valley/nwuwoqpzqnopyvxusoxurwwwpyuslpuk landed: v5 as e9a3f869ac6c80b000d6a229e6f8339d5fc5bff1.
    
    Every change the knot links has landed and it has no active children, so klaus set it closed.