Skip to content
.md

Speculative Checks

Instead of waiting for each PR to complete, the queue can test multiple PRs in parallel by assuming earlier PRs will pass.

Sequential approach — each PR waits for the previous one to finish:

0153045607590PR #1 (test against main) PR #2 (test against main+PR1) PR #3 (test against main+PR1+PR2) QueueSequential: 90 minutes total

Speculative approach — all PRs test in parallel, assuming earlier ones will pass:

051015202530PR #1 (test against main) PR #2 (test against main+PR1) PR #3 (test against main+PR1+PR2) QueueSpeculative: 30 minutes total

3x faster!

  1. PR #1 enters the queue → test against main
  2. PR #2 enters the queue → test against main + PR #1 (assuming #1 will pass)
  3. PR #3 enters the queue → test against main + PR #1 + PR #2 (assuming both will pass)

All three tests run simultaneously.

If PR #1 fails, the speculation for PRs #2 and #3 was wrong. They were tested against a state that will never exist.

What happens:

  • PR #1 is removed from the queue
  • PRs #2 and #3 are automatically re-queued
  • PR #2 now tests against main (not main + PR #1)
  • PR #3 tests against main + PR #2

The speculation was wrong, but we only lost the time for one CI run. On average, this is still much faster than sequential testing.

You can limit how far ahead the queue speculates:

DepthBehavior
1No speculation (sequential)
3Test up to 3 PRs ahead
UnlimitedTest all PRs in parallel

Higher depth = more parallelism but more wasted CI if early PRs fail.

  • Teams with high PR volume
  • Codebases with low failure rates in the queue
  • When CI resources are not a constraint