rayon
Simple, guaranteed data-race-free work-stealing parallelism for Rust — turn sequential iterators parallel by changing one call.
Repository Health
Technical Analysis
Rayon is a lightweight data-parallelism library for Rust that makes it trivial to convert sequential computations into parallel ones. In most cases you simply swap a .iter() call for .par_iter() and Rayon handles dividing the work across a global work-stealing thread pool, dynamically adapting to the runtime workload for maximum throughput.
Built on top of rayon-core, Rayon’s APIs guarantee data-race freedom through Rust’s type system: if your code compiles, it typically produces the same results it did sequentially. Beyond parallel iterators, it exposes lower-level join and scope primitives and configurable thread pools for cases that need finer control.
What You Get
- Parallel iterators (
par_iter,par_iter_mut,into_par_iter) that mirror the standard iterator API - Low-level
joinandscopeprimitives for building custom parallel task trees - Configurable thread pools via
ThreadPoolBuilder, including customization of the global pool - Parallel sorting (
par_sort) and parallel collection extension (par_extend) - A prelude module that brings all the necessary traits into scope with one import
Common Use Cases
- Parallelizing CPU-bound map/filter/reduce pipelines over large slices or vectors
- Speeding up numeric and scientific computations across all available cores
- Sorting large datasets in parallel with
par_sort - Fanning out independent recursive work (e.g. divide-and-conquer algorithms) via
join
Under The Hood
Architecture — Rayon is split into two crates: the user-facing rayon crate (parallel iterators over std types in src/iter, src/slice, src/str, src/collections, plus the prelude) and rayon-core, which houses the runtime — the work-stealing registry.rs, job.rs, latch.rs, the sleep module for idle-thread parking, and the join, scope, spawn, broadcast, and thread_pool primitives. Parallel iterators build a lazy computation graph of producers/consumers that is only executed when a terminal method is called, at which point work is split recursively and fed to the global work-stealing pool.
Tech Stack — Pure Rust (99.98% of the codebase), edition 2024, requiring rustc 1.85+. The runtime depends on crossbeam-deque and crossbeam-utils for lock-free work-stealing deques and synchronization; the public API re-exports either. Optional wasm_sync powers a spin-lock fallback on the browser main thread for wasm32 targets. The workspace also contains rayon-demo for benchmarks and visualizations.
Code Quality — Mature and disciplined. The workspace enforces strict lints (unsafe-op-in-unsafe-fn, unreachable-pub, private-bounds, and rust_2018_idioms all denied/warned). Testing is thorough: 16 integration test files under tests/ cover panic safety, unwind behavior, cross-pool usage, unzip edge cases, and large workloads (octillion.rs), alongside compile_fail tests that assert the type system rejects unsound usage. Roughly 2,300 commits over a decade of maintenance by 160 contributors.
API Design — Exceptionally ergonomic. The core design goal — swap iter() for par_iter() — makes adoption nearly friction-free, and the rayon::prelude::* import brings every needed trait into scope in one line. Naming deliberately mirrors the standard library’s iterator methods, so existing Rust knowledge transfers directly. Documentation is strong: extensive rustdoc with runnable examples, a README quick-start, and a FAQ. The join/scope escape hatches keep advanced control available without complicating the common path.
Used by 22 apps in this directory
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.
TensorZero
Ab Testing Experimentation · AI Development · Monitoring
TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.
Trieve
AI Development · Developer Tools · Search
All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.
Windmill
Automation · Developer Tools
Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.