Commit eb3fc58
feat(orchestrator)!: finalize batches from their speculation paths
## Summary
### Why?
Speculation was building the right things and merging on the wrong rule. A head still waited for *every* dependency to succeed before it could merge — the same rule as before any of this — so a batch built without a slow neighbour sat behind that neighbour anyway. The paths were being earned and then ignored. This is the commit that collects them.
### What?
A head merges once one of its **passed** paths has had every dependency it *assumed would succeed* actually merge; assumed-failing and ignored dependencies impose no wait. That is the whole speedup: the head waits on what its passing build was actually stacked on, not on its full dependency list. A head fails only when no funded path has a future left, and the winner's siblings are superseded — cancelled to free their slots.
Outcomes are reached in `finalize`, before the Speculator is asked, and committed one generation at a time, so a cascade (A fails → B's last path breaks → B fails → maybe C too) resolves in a single run without ever enacting a dependent of an outcome whose own write lost its compare-and-swap. A batch decided by a cascade gets a recovery signal before it turns terminal, since no retry of the triggering message would ever revisit it.
Cancellation joins the run: a cancelling batch is just another batch the run walks — its live paths are marked cancelling, the poll loop stops their builds, and whichever later run sees them all stopped drives the batch to Cancelled. A cancelling path with no build link is cancelled immediately; there is deliberately no reservation state and no staleness bound, so a crashed dispatch can never keep a batch out of its terminal state.
The legacy per-batch finalizer is deleted; `speculate.go` keeps only admission and message routing, and the package doc gains the batch lifecycle, a worked example, and the finalize step.
## Test Plan
✅ `bazel test //submitqueue/orchestrator/...` — the merge rule is table-driven per assumption; failure, cascade commit ordering, and CAS-loss isolation are covered, and cancellation end to end: never-dispatched, live-build, no-paths, and lost-race cases.
✅ `make fmt`, `make gazelle`
# Conflicts:
# submitqueue/orchestrator/controller/speculate/BUILD.bazel
# submitqueue/orchestrator/controller/speculate/speculate_test.go
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# interactive rebase in progress; onto ec05b712
# Last command done (1 command done):
# pick 4462c89 # feat(orchestrator)!: finalize batches from their speculation paths
# No commands remaining.
# You are currently rebasing branch 'preetam/speculation-finalization' on 'ec05b712'.
#
# Changes to be committed:
# modified: submitqueue/orchestrator/controller/cancel/cancel.go
# modified: submitqueue/orchestrator/controller/speculate/BUILD.bazel
# modified: submitqueue/orchestrator/controller/speculate/check.go
# modified: submitqueue/orchestrator/controller/speculate/dispatch.go
# modified: submitqueue/orchestrator/controller/speculate/doc.go
# new file: submitqueue/orchestrator/controller/speculate/finalize.go
# new file: submitqueue/orchestrator/controller/speculate/outcome.go
# new file: submitqueue/orchestrator/controller/speculate/outcome_test.go
# modified: submitqueue/orchestrator/controller/speculate/run.go
# modified: submitqueue/orchestrator/controller/speculate/run_test.go
# modified: submitqueue/orchestrator/controller/speculate/snapshot.go
# modified: submitqueue/orchestrator/controller/speculate/speculate.go
# modified: submitqueue/orchestrator/controller/speculate/speculate_test.go
#
# Conflicts:
# submitqueue/orchestrator/controller/speculate/speculate.go
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# interactive rebase in progress; onto 9a490fe
# Last command done (1 command done):
# pick ec12146f # feat(orchestrator)!: finalize batches from their speculation paths
# No commands remaining.
# You are currently rebasing branch 'preetam/speculation-finalization' on '9a490fe4'.
#
# Changes to be committed:
# modified: submitqueue/orchestrator/controller/speculate/BUILD.bazel
# modified: submitqueue/orchestrator/controller/speculate/check.go
# modified: submitqueue/orchestrator/controller/speculate/dispatch.go
# modified: submitqueue/orchestrator/controller/speculate/doc.go
# new file: submitqueue/orchestrator/controller/speculate/finalize.go
# new file: submitqueue/orchestrator/controller/speculate/outcome.go
# new file: submitqueue/orchestrator/controller/speculate/outcome_test.go
# modified: submitqueue/orchestrator/controller/speculate/run.go
# modified: submitqueue/orchestrator/controller/speculate/run_test.go
# modified: submitqueue/orchestrator/controller/speculate/snapshot.go
# modified: submitqueue/orchestrator/controller/speculate/speculate.go
# modified: submitqueue/orchestrator/controller/speculate/speculate_test.go
#
# Conflicts:
# submitqueue/orchestrator/controller/speculate/dispatch.go
# submitqueue/orchestrator/controller/speculate/run.go
# submitqueue/orchestrator/controller/speculate/run_test.go
# submitqueue/orchestrator/controller/speculate/speculate.go
# submitqueue/orchestrator/controller/speculate/speculate_test.go
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# interactive rebase in progress; onto e6ea890a
# Last command done (1 command done):
# pick 25e0321 # feat(orchestrator)!: finalize batches from their speculation paths
# No commands remaining.
# You are currently rebasing branch 'preetam/speculation-finalization' on 'e6ea890a'.
#
# Changes to be committed:
# modified: submitqueue/orchestrator/controller/speculate/BUILD.bazel
# modified: submitqueue/orchestrator/controller/speculate/check.go
# modified: submitqueue/orchestrator/controller/speculate/dispatch.go
# modified: submitqueue/orchestrator/controller/speculate/doc.go
# new file: submitqueue/orchestrator/controller/speculate/finalize.go
# new file: submitqueue/orchestrator/controller/speculate/outcome.go
# new file: submitqueue/orchestrator/controller/speculate/outcome_test.go
# modified: submitqueue/orchestrator/controller/speculate/run.go
# modified: submitqueue/orchestrator/controller/speculate/run_test.go
# modified: submitqueue/orchestrator/controller/speculate/snapshot.go
# modified: submitqueue/orchestrator/controller/speculate/speculate.go
# modified: submitqueue/orchestrator/controller/speculate/speculate_test.go
#1 parent 8d5a6c2 commit eb3fc58
12 files changed
Lines changed: 1860 additions & 1038 deletions
File tree
- submitqueue/orchestrator/controller/speculate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | | - | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
129 | | - | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
Lines changed: 23 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
42 | | - | |
| 50 | + | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
| |||
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
60 | | - | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
101 | 109 | | |
102 | 110 | | |
103 | 111 | | |
104 | | - | |
105 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
106 | 115 | | |
107 | 116 | | |
108 | 117 | | |
| |||
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
114 | | - | |
| 123 | + | |
115 | 124 | | |
116 | 125 | | |
117 | | - | |
| 126 | + | |
118 | 127 | | |
119 | | - | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
125 | | - | |
| 134 | + | |
126 | 135 | | |
127 | 136 | | |
128 | | - | |
| 137 | + | |
129 | 138 | | |
130 | | - | |
| 139 | + | |
| 140 | + | |
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
| 27 | + | |
32 | 28 | | |
33 | 29 | | |
34 | 30 | | |
| |||
38 | 34 | | |
39 | 35 | | |
40 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
| |||
46 | 62 | | |
47 | 63 | | |
48 | 64 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
| |||
58 | 75 | | |
59 | 76 | | |
60 | 77 | | |
61 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
62 | 81 | | |
63 | 82 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
69 | 99 | | |
70 | 100 | | |
71 | 101 | | |
| |||
75 | 105 | | |
76 | 106 | | |
77 | 107 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
83 | 114 | | |
84 | 115 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
88 | 120 | | |
89 | 121 | | |
90 | 122 | | |
| |||
0 commit comments