Commit e2dbb16
committed
distribution(composed1): break+compact+rename per claude review on PR #894
Three findings from claude's review of PR #894, all valid:
* OwnerOf O(N)-vs-O(early-break) on sorted route list. Routes
are sorted by Start (UpdateRoute / routesFromCatalog keep them
sorted; recordHistorySnapshotLocked clones from that order).
Once key < r.Start, no later route can cover key either.
`continue` worked but iterated the whole tail; `break` short-
circuits. Matters because M3 puts OwnerOf on every txn
commit's apply path.
* historyOrder backing-array growth on FIFO eviction. The
previous `e.historyOrder = e.historyOrder[1:]` only moved the
slice header — the head of the original backing array stayed
alive across evictions, growing unboundedly. Replace with an
explicit `make([]uint64, len-1, historyDepth) + copy` so the
array stays bounded at historyDepth.
* recordHistorySnapshot lock contract fragility. The function
requires the caller to hold e.mu (write lock); the doc said
so but nothing in the name signalled it. Renamed to
recordHistorySnapshotLocked per the Go convention so a future
refactor that moves the call past an Unlock surfaces the
contract by name.
Test nits also addressed:
* TestEngineSnapshotAt_FIFOEviction now calls t.Parallel() and
the direct `e.historyDepth = 3` write is documented as
test-local (Engine not yet shared with any concurrent
reader).
* TestKvFSM_WithRouteHistory_NilProviderTreatedAsUnwired asserts
shardGroupID=7 explicitly so a future refactor that
accidentally zeroes it would be caught.
Verification: go test -race -count=1 ./distribution ./kv → pass
(1.0 s + 8.1 s). No spec change; no contract change visible to
callers outside the distribution package.1 parent 85056fa commit e2dbb16
3 files changed
Lines changed: 44 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
163 | | - | |
| 172 | + | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
| |||
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
200 | 212 | | |
201 | 213 | | |
202 | 214 | | |
| |||
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
213 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
214 | 236 | | |
215 | 237 | | |
216 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| 562 | + | |
562 | 563 | | |
563 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
564 | 570 | | |
565 | 571 | | |
566 | 572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
97 | 100 | | |
0 commit comments