---
title: "Build the merge-queue speculations most likely to be needed"
description: "Analyze conflicts between queued changes, build independent ones concurrently, and spend CI on the speculative builds most likely to decide a change."
url: https://starsling.dev/ci-playbooks/techniques/prioritize-speculative-builds
canonicalUrl: https://starsling.dev/ci-playbooks/techniques/prioritize-speculative-builds
---

# Build the merge-queue speculations most likely to be needed

Analyze conflicts between queued changes, build independent ones concurrently, and spend CI on the speculative builds most likely to decide a change.

## How to choose an approach

This technique currently has one documented company example. Validate its prerequisites, tradeoffs and original CI environment against your repository before adapting it.

- **[Uber](https://starsling.dev/ci-playbooks/uber#prioritize-speculative-builds)**: Use it when The repository lands changes through a merge queue, and queued builds are often cancelled or rebuilt when an earlier change lands. Check before adopting: A threshold set too high makes changes wait longer under heavy load; Uber tunes it from historical build data for each monorepo. Adapted for GitHub Actions; compare the original system with yours.

## Apply this technique

````text
Evaluate and apply this CI technique to my repository: Build the merge-queue speculations most likely to be needed.

Analyze conflicts between queued changes, build independent ones concurrently, and spend CI on the speculative builds most likely to decide a change.

Read the technique and its source-backed company examples: https://starsling.dev/ci-playbooks/techniques/prioritize-speculative-builds.md

Inspect this repository’s CI workflows, build and test commands, dependencies, and recent run timings. Identify where this technique applies and explain the expected benefit using this repository’s evidence.
Measure a baseline from recent comparable runs: elapsed time, queue time, runner minutes and failures where available. If data is unavailable, say what cannot be measured.
Compare relevant company approaches, checking prerequisites, platform differences and tradeoffs. Rank applicable options by evidence, fit and measurable opportunity; do not present company results as predictions for this repo.
Recommend the smallest safe change, show what checks and fallback paths remain, and ASK ME WHICH CHANGE TO APPROVE BEFORE EDITING ANY FILES.
Only after approval, work on a new feature branch, make one reversible change, and open a reviewable pull request. Never merge or push to a default or protected branch.
Keep required checks, test coverage, deployment and release behavior intact. Validate the change and compare equivalent runs where possible; report limitations and what should be monitored after merge.
````

## How Uber used this technique

Read what Uber changed and follow the original sources.

### Uber: Build the merge-queue speculations most likely to be needed

**Translated to GitHub Actions**

- What Uber built: Uber's SubmitQueue builds a tree of speculative builds and ranks each by the chance its result decides a change.
- Your GitHub Actions version: In a merge queue, build the speculations most likely to be needed first and run changes that touch different targets concurrently.

SubmitQueue speculates on the outcome of every pending change and builds a tree of the possible builds. Its conflict analysis prunes that tree so changes touching different targets build concurrently. A probabilistic model, fed by predicted build times and a success predictor, ranks each speculative build by the chance its result decides a change. Only builds above a threshold run, and smaller changes that can bypass a large conflicting change ahead of them get priority.

Evidence: Company-reported result or observation

Across the Go, iOS and Android monorepos, CPU hours fell 44.70% for Go (1,485 to 821 hours), 34.86% for iOS (472 to 307) and 52.23% for Android (729 to 348). ([Source](https://www.uber.com/us/en/blog/slashing-ci-costs-at-uber/))

P95 waiting time fell 44.67% for Go (33.69 to 18.64 minutes), 33.32% for iOS (14.86 to 9.91) and 31.66% for Android (25.36 to 17.33). ([Source](https://www.uber.com/us/en/blog/slashing-ci-costs-at-uber/))

Use it when: The repository lands changes through a merge queue, and queued builds are often cancelled or rebuilt when an earlier change lands.

Before applying it: A threshold set too high makes changes wait longer under heavy load; Uber tunes it from historical build data for each monorepo.

GitHub Actions adaptation: Compare the source system with your own workflow before applying this translation.

[Read more in the Uber playbook](https://starsling.dev/ci-playbooks/uber#prioritize-speculative-builds)

[Primary source](https://www.uber.com/us/en/blog/slashing-ci-costs-at-uber/)

## CI optimization is continuous work.

Apply this technique yourself, or use StarSling Runners for faster GitHub Actions and optional agent-driven optimization PRs, which teams on eligible paid plans can turn on.

[Get self-improving CI](https://starsling.dev/products/runners)

## Company Playbooks

### [Anthropic](https://starsling.dev/ci-playbooks/anthropic)

Run only affected tests

### [DoorDash](https://starsling.dev/ci-playbooks/doordash)

Run build and test in parallel, sharded across CI agents

### [Linear](https://starsling.dev/ci-playbooks/linear)

Benchmark the same job on faster hardware

### [Mastra](https://starsling.dev/ci-playbooks/mastra)

StarSling runners for the slowest test workflow

### [OpenAI](https://starsling.dev/ci-playbooks/openai)

Rank CI fixes by the minutes they save

### [Ramp](https://starsling.dev/ci-playbooks/ramp)

Move a CPU-bound test suite to a faster CPU

### [Shopify](https://starsling.dev/ci-playbooks/shopify)

Let an agent iterate against one CI metric

### [Spotify](https://starsling.dev/ci-playbooks/spotify)

Build arm64 on native arm64 runners

### [Stripe](https://starsling.dev/ci-playbooks/stripe)

Run only the tests a change can reach

### [Uber](https://starsling.dev/ci-playbooks/uber)

Build the merge-queue speculations most likely to be needed
