Shuttle

A Rust library for testing concurrent code by controlling and randomizing thread scheduling to reliably surface race conditions.

Library
Cargo
v0.9.2
1,042stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity92
Maintenance76
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture89
Code Quality88
Innovation90
Learning Curve62

Shuttle, from AWS Labs, is a library for testing concurrent Rust code using randomized concurrency testing techniques such as PCT (Probabilistic Concurrency Testing). By taking control of thread scheduling and exploring interleavings randomly, Shuttle reliably surfaces race conditions and deadlocks that would only appear intermittently under the real OS scheduler, and it reproduces any failing schedule deterministically for debugging.

What You Get

  • Drop-in replacements for std::sync, threads, and collections used by the controlled scheduler
  • Randomized schedulers implementing PCT and other probabilistic bug-finding techniques
  • Deterministic replay of any failing schedule for debugging under a debugger
  • Wrappers that make code using tokio, rand, and standard primitives testable

Common Use Cases

  • Finding data races and deadlocks in lock-based concurrent Rust code
  • Deterministically reproducing a flaky concurrency failure to debug it
  • Adding concurrency regression tests to CI for synchronization-heavy crates

Under The Hood

Architecture

Shuttle is organized as a Cargo workspace: shuttle-core holds the scheduler runtime, shuttle-std provides the instrumented std replacements, shuttle-schedulers implements the scheduling algorithms (random, PCT), and shuttle-explorer supports exploration. Tests call entry points like check_random, which run the test closure repeatedly, each time letting the scheduler decide the order in which instrumented threads make progress.

Tech Stack

Rust library crate targeting stable Rust, built as a multi-crate workspace. It instruments concurrency primitives and integrates with tokio and rand via optional wrappers. Published on crates.io as shuttle, licensed Apache-2.0.

Code Quality

As an AWS Labs project it carries production-grade rigor: a dedicated tests directory, CI workflows, a CHANGELOG, code of conduct, and contributing guidelines. The scheduler logic is the tested core, and the crate is actively developed with frequent releases.

API Design

The primary API is intentionally small: swap std concurrency imports for shuttle ones and wrap the test in a check_* function. This keeps the mental model close to ordinary Rust threading, though understanding the randomized-scheduling model and wrapper coverage takes some ramp-up.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search