Skip to content

feat(speculation): standard composed speculator - #451

Open
behinddwalls wants to merge 1 commit into
preetam/speculation-allocatorfrom
preetam/speculation-standard
Open

feat(speculation): standard composed speculator#451
behinddwalls wants to merge 1 commit into
preetam/speculation-allocatorfrom
preetam/speculation-standard

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

The three branches below this one define the pieces: the Speculator contract (#445), a Generator that ranks candidate paths (#446), and an Allocator that spends the build budget on them (#450). This one joins them up.

Keeping the composition in its own implementation means a queue can change how paths are scored, or how the budget is rationed, independently — and without either choice reaching the Speculator contract the controller depends on.

What?

Adds submitqueue/extension/speculation/speculator/standard.

Speculate opens the generator over the queue's batches and path sets, then hands the resulting candidate iterator to the allocator. That is the whole implementation: it makes no decision of its own, so its behavior is entirely the behavior of the two parts it is built from. Pairing bestfirst with sticky gives the default policy — rank paths by how likely their guesses are to hold, fill the free budget in that order, never preempt a running build.

Also adds a note to the speculator package README.md describing the composition.

Test Plan

bazel test //submitqueue/extension/speculation/... (3 targets), make lint, make check-gazelle

One end-to-end test wires the real bestfirst and sticky together and checks the pair proposes only builds, and that the funded path for a dependent batch is the optimistic guess. Two mock-based tests cover the wiring itself: that the iterator the generator returns is the one handed to the allocator, and that a generator error propagates rather than being swallowed.

Note the commit also updates a sticky.New call site for the logger argument added in #450 — the signature change landed there, and this is the only caller.

Stack

  1. feat(entity): speculation path and run entities #444
  2. feat(speculation): speculator extension contract #445
  3. feat(speculation): generator contract and bestfirst impl #446
  4. feat(speculation): allocator contract and sticky impl #450
  5. @ feat(speculation): standard composed speculator #451


Like the other extensions, a `Speculator` is selected **per queue** by the wiring layer through the `Config` (queue name) and `Factory` interface. Budget, depth bound, clock, and any extra data are injected at construction by the integrator, not carried on the contract.

## The `standard` Speculator

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.

move to "standard"'s README
The description should say not how it is composed, but what it does (what behavior it implements wrt prioritizing paths and working with build budget).

@behinddwalls
behinddwalls force-pushed the preetam/speculation-standard branch from 19ee301 to 8dcd084 Compare July 29, 2026 18:12
Add submitqueue/extension/speculation/speculator/standard, the standard Speculator composed from a Generator and an Allocator. It decides nothing itself — it opens the generator's candidate stream and hands it to the allocator — so its behavior is entirely that of the two parts it is built from. Pairing bestfirst with sticky yields the default speculation policy.
@behinddwalls
behinddwalls force-pushed the preetam/speculation-standard branch from 8dcd084 to e8a2e32 Compare July 29, 2026 18:24
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