Skip to content

feat(speculation): allocator contract and sticky impl - #450

Merged
behinddwalls merged 1 commit into
mainfrom
preetam/speculation-allocator
Aug 7, 2026
Merged

feat(speculation): allocator contract and sticky impl#450
behinddwalls merged 1 commit into
mainfrom
preetam/speculation-allocator

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

Ranked candidates need a budget policy: something must decide which paths get the queue's limited concurrent-build slots, without double-funding paths that are already running or finished.

What?

Adds submitqueue/extension/speculation/allocator — the budget-spending contract the standard Speculator hands its candidate stream to — plus the sticky implementation and mocks.

The Allocator owns terminal-path suppression: it reconciles the stream against the stored path sets by path ID, so an in-flight candidate keeps the slot it already holds and a terminal one is skipped. Budget accounting reads path status and nothing else — pending, building, and cancelling paths hold a slot until their builds actually stop — and the unit is deliberately coarse: one slot per concurrent build.

sticky fills only free slots and never preempts a running build; its policy counterpart is a preempting allocator. Output is all-or-nothing (a partial list would fund an arbitrary prefix of the ranking), and a stored path with no status fails fast rather than guessing whether it holds a slot.

Test Plan

bazel test //submitqueue/extension/speculation/allocator/... — terminal candidates skipped per status, in-flight candidates kept, budget exhaustion, context cancellation, corrupt-status failure.

make fmt, make gazelle, make mocks

Issues

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical comment about failing fast

Comment thread submitqueue/extension/speculation/allocator/README.md Outdated
Comment thread submitqueue/extension/speculation/allocator/README.md Outdated
Comment thread submitqueue/extension/speculation/allocator/sticky/sticky.go Outdated
Comment thread submitqueue/extension/speculation/allocator/sticky/sticky.go Outdated
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch 2 times, most recently from bf09ae6 to 6977b91 Compare July 29, 2026 18:24
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch 2 times, most recently from d6f1dfe to af1efe4 Compare July 29, 2026 22:41
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch 2 times, most recently from 2b3a122 to 32e21b9 Compare July 29, 2026 23:18
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 32e21b9 to 00ca258 Compare July 29, 2026 23:18
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 00ca258 to 80c246f Compare July 30, 2026 01:19
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 80c246f to 0049b73 Compare July 30, 2026 07:31
@behinddwalls
behinddwalls requested a review from sbalabanov July 30, 2026 07:37
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch 2 times, most recently from 3550e38 to c2e9d09 Compare August 5, 2026 04:57
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from c2e9d09 to 2c300da Compare August 5, 2026 17:05
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 2c300da to 011d74b Compare August 5, 2026 17:28
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 011d74b to 5bdb606 Compare August 5, 2026 19:05
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 5bdb606 to 90cb357 Compare August 6, 2026 02:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch 2 times, most recently from c792196 to 9aab8df Compare August 6, 2026 03:04
@behinddwalls

behinddwalls commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

critical comment about failing fast

i think we need log but not fail as there is no way to get rid of it afterwords; i will take care of it separately

@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 9aab8df to 3af3a79 Compare August 6, 2026 03:17
Base automatically changed from preetam/speculation-generator to main August 6, 2026 03:32
## Summary

### Why?

Ranked candidates need a budget policy: something must decide which paths get the queue's limited concurrent-build slots, without double-funding paths that are already running or finished.

### What?

Adds `submitqueue/extension/speculation/allocator` — the budget-spending contract the standard Speculator hands its candidate stream to — plus the `sticky` implementation and mocks.

The Allocator owns terminal-path suppression: it reconciles the stream against the stored path sets by path ID, so an in-flight candidate keeps the slot it already holds and a terminal one is skipped. Budget accounting reads path status and nothing else — pending, building, and cancelling paths hold a slot until their builds actually stop — and the unit is deliberately coarse: one slot per concurrent build.

`sticky` fills only free slots and never preempts a running build; its policy counterpart is a preempting allocator. Output is all-or-nothing (a partial list would fund an arbitrary prefix of the ranking), and a stored path with no status fails fast rather than guessing whether it holds a slot.

## Test Plan

✅ `bazel test //submitqueue/extension/speculation/allocator/...` — terminal candidates skipped per status, in-flight candidates kept, budget exhaustion, context cancellation, corrupt-status failure.

✅ `make fmt`, `make gazelle`, `make mocks`
@behinddwalls
behinddwalls force-pushed the preetam/speculation-allocator branch from 3af3a79 to 78100ef Compare August 6, 2026 03:32
@behinddwalls
behinddwalls added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit 74a734a Aug 7, 2026
15 checks passed
@behinddwalls
behinddwalls deleted the preetam/speculation-allocator branch August 7, 2026 01:10
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.

3 participants