Skip to content

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

Open
behinddwalls wants to merge 1 commit into
preetam/speculation-generatorfrom
preetam/speculation-allocator
Open

feat(speculation): allocator contract and sticky impl#450
behinddwalls wants to merge 1 commit into
preetam/speculation-generatorfrom
preetam/speculation-allocator

Conversation

@behinddwalls

@behinddwallsbehinddwalls 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

Stack

  1. docs(rfc): explain best-first speculation generation #513
  2. feat(speculation): generator contract and bestfirst impl #446
  3. @ feat(speculation): allocator contract and sticky impl #450
  4. feat(speculation): standard composed speculator #451
  5. feat(storage): speculation path set store #501
  6. feat(storage): path-build link store for per-path builds #502
  7. feat(orchestrator): dispatch builds per speculation path #503
  8. feat(orchestrator): poll builds and stop the ones nothing wants #504
  9. fix(orchestrator): mint distinct message IDs for cancel re-publishes #505
  10. feat(orchestrator): re-plan the queue from the Speculator each run #506
  11. feat(orchestrator)!: finalize batches from their speculation paths #507
  12. feat(orchestrator): compose per-queue speculators and turn speculation on #508

@sbalabanovsbalabanov 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 threadsubmitqueue/extension/speculation/allocator/README.md Outdated
Comment threadsubmitqueue/extension/speculation/allocator/README.md Outdated
Comment threadsubmitqueue/extension/speculation/allocator/sticky/sticky.go Outdated
Comment threadsubmitqueue/extension/speculation/allocator/sticky/sticky.go Outdated
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch 2 times, most recently from bf09ae6 to 6977b91CompareJuly 29, 2026 18:24
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch 2 times, most recently from d6f1dfe to af1efe4CompareJuly 29, 2026 22:41
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch 2 times, most recently from 2b3a122 to 32e21b9CompareJuly 29, 2026 23:18
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 32e21b9 to 00ca258CompareJuly 29, 2026 23:18
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 00ca258 to 80c246fCompareJuly 30, 2026 01:19
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 80c246f to 0049b73CompareJuly 30, 2026 07:31
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch 2 times, most recently from 8a57108 to 9f63cadCompareAugust 3, 2026 23:03
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 9f63cad to 5a83bb7CompareAugust 4, 2026 01:58
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 5a83bb7 to 23a30adCompareAugust 4, 2026 05:11
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 23a30ad to 565e1c1CompareAugust 5, 2026 03:15
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from 565e1c1 to e5fbcaaCompareAugust 5, 2026 03:25
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from e5fbcaa to f4229e3CompareAugust 5, 2026 03:37
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from f4229e3 to c33ce35CompareAugust 5, 2026 03:43
@behinddwalls
behinddwallsforce-pushed the preetam/speculation-allocator branch from c33ce35 to 3550e38CompareAugust 5, 2026 04:11
## 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`
Sign up for freeto 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

@behinddwalls@sbalabanov