Skip to content

A slot stays free while a red candidate's first round runs (draft) - #16

Closed
jeremy wants to merge 3 commits into
mainfrom
slot-hold
Closed

jeremy wants to merge 3 commits into
mainfrom
slot-hold

Conversation

@jeremy

@jeremy jeremy commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Context

When a candidate on the trunk fails, its first round of probes clears every pull request outside the suspects, and they are free to be built again. Meanwhile the chain goes on taking free slots for newer pull requests, so those the round clears often find every slot taken. In one queue's records, 16 to 24 Nov, pull requests cleared by a round and then waiting for a build spent 526 pull-request minutes so, 346 of them with every slot taken; in one episode on 25 Nov seven waited 25 minutes after the last slot went to two newer ones, two minutes before the round read.

Action

One setting, spare, off unless set. With it, where slots is two or more, while a red candidate of several pull requests built on the trunk's tip has its first round running, fill uses one slot fewer. It is a limit on the slots the chain fills, not a push: gather may still hold a cleared pull request back, and a landing or an ejection in the tick ends the plan before fill. The round's read ends the hold whatever it says, as does the red candidate going or the trunk moving past its base; a round that never reports reads as lost after timeout, and where timeout is zero only those end it.

read, judge, weigh, suspects, stackedOn, the rounds and their probes are as they were: against main the planner's diff is clearing and the slot count in fill.

Decision

Draft: it merges after the simulator's score of 27 Nov.

The first commit also ended the wait beside a candidate stacked on the red one once the first round had read. A review showed that changes who leaves: where #3 repairs what #2 breaks, the chain built #1 and #3 beside the candidate of all three, and #3 left on that build's own fair test where the stacked candidate would have landed all three. The second commit takes it out, and TestTheChainWaitsForACandidateStackedOnARedOneWhereItMayLandAllOfThem holds the sequence with spare set and unset. The checker does not model one pull request repairing another, so that test is the only thing that does.

A second review found no way of taking a pull request out wrongly that spare adds. Like any setting that moves when a candidate is built, it can change who leaves where one pull request repairs another: the planner as it stands has that case with other arrival times.

What the hold changes beyond the wait it saves, each held by a test:

  • A suspect is judged on other trees sooner. A red and its evidence go when a pull request below the suspect lands before the fair test ends, today as well (TestASuspectWalksBackInWhenAPullRequestBelowItLandsBeforeItsFairTestEnds). With whole-build rounds spare makes that likelier: the suspect is built again on the new trunk and leaves a cycle later (TestSpareLetsTheClearedLandBeforeTheSuspectsFairTestEnds), or lands there if a later arrival repaired it (TestASuspectALaterArrivalRepairsLeavesOnTheOldTreesOrLandsOnTheNewTrunk). It lands only on a whole build that passed. With probes a whole build of the cleared pull requests rarely beats the rounds.
  • A flake costs no build more. With whole-build rounds the cleared pull requests land first on as many whole builds; with probes the builds are the same with spare as without (TestWithSpareAFlakeOfWholeBuildsLandsTheClearedFirstOnAsManyBuilds).

Outcome

With spare unset the planner's actions are main's: the existing tests are untouched, and the row for one recorded day is identical to main's but for commit. The checker holds every invariant with spare set (TestCheckerCurrentPlannerWithSpare: 594,654 states, 0 broken). Replayed from its recording, the tick of 25 Nov 02:23:39Z pushes no candidate with spare, where the live queue pushed its third.

With `spare` set, while a red candidate of several pull requests on the
trunk has its first round running, the chain takes one slot fewer, so
those the round clears are pushed in the tick it reads. The round's read
ends the hold whatever it says, as does the red candidate going; a round
that never reports reads as lost after the timeout. The same read ends
the wait for probes beside a candidate stacked on the red one.

Off unless set. Nothing that decides who is a suspect or who leaves
changes: only fill's slot count and the stacked candidate's wait.
The shorter wait beside a candidate stacked on a red one changed who
leaves: where #3 repairs what #2 breaks, it built #1 and #3 beside the
candidate of all three, and #3 left on that build's own fair test where
the stacked candidate would have landed all three. The chain waits for
the probes as it did before, and spare is the slot hold alone.

The hold is a limit: fill uses one slot fewer while the first round of a
red candidate of several pull requests on the trunk runs. Gather may
still hold a cleared pull request back, a landing or an ejection in the
tick ends the plan before fill, and where the timeout is zero a round
that never reports holds the slot while the red stands.

Tests: the repairing pull request lands with the stacked candidate,
with spare and without; a suspect a later arrival repairs leaves on the
old trees without spare and lands on the new trunk with it; a cleared
pull request alone waits under gather; the hold under a zero timeout; a
flake of whole-build rounds lands the cleared first on as many builds,
and one of probes builds the same with spare as without.
@jeremy jeremy changed the title A slot stays free for the pull requests a red candidate's first round clears (draft) A slot stays free while a red candidate's first round runs (draft) Nov 25, 2026
The hold needs two slots or more and a red candidate built on the
trunk's tip, and ends when the trunk moves past that base as well as
when the round reads or the red goes: the docs now say so. Blame says
the chain waits for a pending stacked candidate after the first round
has answered, which is what the planner does.

In the repair sequence a candidate of #1 alone now builds slowly, so a
planner that built #1 and #3 beside the stacked candidate would take #3
out at tick 9 before #1 could land and drop the evidence.
@jeremy
jeremy marked this pull request as ready for review November 25, 2026 12:27
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The merge-gating 27 Nov simulator score is still pending, requiring human review of the scheduling change’s latency, throughput, and suspect-retesting trade-offs against the charter.

No open issues 🎉

What changed in this PR

Adds an opt-in spare setting to Banyan’s merge queue, leaving capacity for pull requests cleared by a failed candidate’s first diagnostic round. The setting is off by default.

Changes:

  • Fills one fewer candidate slot during qualifying first rounds when at least two slots are configured.
  • Adds regression tests for slot release, scheduling interactions, flakes, and repairing pull requests, plus invariant checks with spare enabled.
  • Documents the setting’s limits and clarifies existing stacked-candidate behavior.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
README.md Introduces the spare setting and its purpose.
internal/​run/​run.go Passes spare from runtime configuration to the planner.
internal/​queue/​world.go Adds the queue’s Spare configuration field.
internal/​queue/​plan.go Reduces slot filling during qualifying first rounds.
internal/​queue/​plan_test.go Adds tick-by-tick scheduling and regression coverage.
eval/​check_test.go Checks planner invariants with spare enabled.
doc/​design.md Explains slot reservation, release conditions, and existing blame behavior.

Review effort: Balanced

@jeremy

jeremy commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

🤖 Held, not to merge: an outside read of this diff found that spare changes who lands and who is taken out. Back to draft until Jeremy decides.

What the read found, each traced by hand from the code and not yet run:

  1. A pull request is taken out after the one it needs has landed. Two slots, batch 2, probes on. Queue Score the stale-head repair and after-merge iPhone tests of hey-native-apps in the eval #1 to Charter: targets from the live rows of 16 to 18 Nov #4; a tree fails when it holds A pushed head waits for every admitting check of its own #2 or Charter: targets from the live rows of 16 to 18 Nov #4 without The head branch settles a pull ref that fell behind #3. [1,2] is red, its first round is pending, The head branch settles a pull ref that fell behind #3's own checks are pending and Charter: targets from the live rows of 16 to 18 Nov #4 is ready. Unset, the second slot builds [4,3] once The head branch settles a pull ref that fell behind #3 is ready and both land. Set, the slot stays empty; [4] fails alone, [3] lands in the freed slot, and Charter: targets from the live rows of 16 to 18 Nov #4's rounds on the old base then take it out while every tree on the current trunk passes.
  2. The repair test in this diff already shows the other direction. Unset, A held trunk's note says what the hold stops #7 lands at tick 27 and the old evidence takes A pushed head waits for every admitting check of its own #2 out at tick 32. Set, Score the stale-head repair and after-merge iPhone tests of hey-native-apps in the eval #1 lands with A held trunk's note says what the hold stops #7 at tick 31 and A pushed head waits for every admitting check of its own #2 lands at tick 42. A better outcome, and a different pull request leaving.
  3. A red trunk that would recover can wait for good. A head moves during the first round and the repair needs both a pull request with the fix label and one without. Unset, the free slot builds them together and the trunk recovers. Set, the slot is kept back until only the labelled one may be built, which fails alone at every recheck.

With spare unset the read found no plan that differs from edf7b8c.

The first two are changes to what takes a pull request out, which this pull request said it did not make. #19 is stacked on this and waits with it; the read's four notes on the checker are on #19.

@jeremy
jeremy marked this pull request as draft November 26, 2026 09:45
@jeremy

jeremy commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

🤖 The three worlds above are now run, as tests on a scratch branch off this head (not pushed; the planner untouched). Each asserts the whole trace for both settings and, at every take-out, whether the trunk at that tick plus the pull requests ahead plus the one taken out passes.

World spare unset spare set
1. #4 needs #3, which is still awaiting its own checks [4,3] lands both; nobody is taken out #4 is taken out at tick 35, after #3 landed at tick 32, though the trunk with [1,2,4] passes
2. The repair test in this diff #2 is taken out at tick 32, though the trunk (with #7 landed) plus [1,2] passes nobody is taken out; #2 lands at tick 42
3. A head moves in round one; the repair needs #4 (fix label) and the new #3 [4,3'] lands at tick 22 and the queue drains [4] is built once, alone, and fails; nothing lands through tick 71 and the new #3 is never built

Two things the run adds to the reading:

  • World 1 needs the round-one probes to take as long as a whole build. Where probes answer in a fraction of one, as doc/design.md expects, the order it depends on does not arise.
  • World 2's take-out with spare unset is today's planner taking out a pull request the charter's invariant 3 calls innocent. spare removes that one and adds world 1's.

So spare moves who is taken out in both directions and can stop a red trunk recovering. It stays a draft for Jeremy.

@jeremy

jeremy commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

🤖 Closing this unmerged. The branch stays; nothing here is lost.

Each option was argued at its strongest and then attacked, with one outside read of both diffs, and the benefit was measured at its most generous.

What spare could save, at most. For each day's landings on the queue this was written for, the minutes a pull request spent cleared by a round and waiting with every slot taken were subtracted from its wait, and the day recomputed. The heads whose builds the hold would put off were charged nothing.

Days, 17 to 27 Nov Landings touched p90 of minutes the queue adds Landings held over 30 min
19 Nov 14 154.7 → 139.8 39 → 39
24, 25, 27 Nov 2, 7, 6 unchanged unchanged
the other seven 0 unchanged unchanged

A pull request cleared after a red candidate has already waited a build, so the saved slot wait never brings one under 30 minutes, and the one day p90 moves it stays seven times its target.

What it costs. The three worlds in the comments above stand: it takes out a pull request the trunk would pass with (where probes are as slow as a build), and it makes reachable, on a schedule that drains today, a red trunk that never recovers. It also removes one wrong take-out today's planner makes. Those are changes to who is taken out, for a wait that does not move a charter figure.

The strongest case for keeping it was a narrower hold: only once the round's bare-trunk probe has passed. That excludes both bad worlds and gives up every case where the last slot fills before that probe answers, so it saves less than the table above.

What would reopen it: recorded days where that narrower hold takes 5% or more off the day's p90, or brings landings under 30 minutes.

The checker work stacked on this (#19) does not need the setting: three of its tests name spare and run as well without it. It moves onto main in its own pull request. The wrong take-out world 2 shows in today's planner is held there as a test that expects the counterexample.

@jeremy jeremy closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants