A Rust crate of concurrency tools: lock-free queues, work-stealing deques, channels, epoch-based GC, atomics and scoped threads.
rayon-rs/rayon
A Rust data-parallelism library that turns sequential iterators into parallel ones with a near drop-in API change.
- Stars
- 13,399
- Forks
- 618
- Open issues
- 233
- Last commit
- 2 months ago
What is it?
Rayon is a data-parallelism library for Rust. Its main interface, the parallel iterator, lets developers convert a sequential computation into a parallel one by changing a call such as iter() to par_iter(). Rayon then decides how to split the work into tasks and adapts that division to maximize performance.
For more control, Rayon provides join and scope functions for creating parallel tasks manually, as well as custom thread pools in place of the default global pool. Its APIs are designed to guarantee data-race freedom, so code that compiles generally behaves as it did sequentially. Parallel iterators produce the same results as their sequential counterparts, with the caveat that side effects such as channel sends or disk writes may occur in a different order.
Rayon is published on crates.io and requires rustc 1.85 or later. On WebAssembly it falls back to sequential iteration by default, and multithreading there requires an adapter such as wasm-bindgen-rayon.
Key features
- 01Converts sequential iterators to parallel ones with a small change such as iter() to par_iter().
- 02Provides join and scope functions for manually creating parallel tasks.
- 03Supports custom thread pools in addition to the default global pool.
- 04Designed to guarantee data-race freedom at the API level.
- 05Offers alternative parallel versions of some sequential iterator methods.
Use cases
- Speeding up CPU-bound loops over large collections in Rust applications.
- Parallelizing data transformations such as map, filter, and sum over slices or vectors.
- Building custom task-parallel workloads with join, scope, or dedicated thread pools.
- Running Rust code with multithreading in the browser via wasm-bindgen-rayon.
Quick start
- 1
Add Rayon to your Cargo.toml dependencies
[dependencies] rayon = "1.12" - 2
Bring the parallel iterator traits into scope in each module
use rayon::prelude::*; - 3
Change foo.iter() to foo.par_iter() to run the iterator in parallel
Things to know
- Requires rustc 1.85.0 or newer.
- Under WebAssembly it falls back to sequential iteration unless you add the separate wasm-bindgen-rayon adapter and configuration.
Topics
FAQ
- What is rayon?
- A Rust data-parallelism library that turns sequential iterators into parallel ones with a near drop-in API change. Rayon is a data-parallelism library for Rust. Its main interface, the parallel iterator, lets developers convert a sequential computation into a parallel one by changing a call such as iter() to par_iter(). Rayon then decides how to split the work into tasks and adapts that division to maximize performance.
- Is rayon free to use? What license does it have?
- rayon is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is rayon still maintained?
- Updated within 6 months. The last commit to rayon was on Aug 28, 2026.
- What can I use rayon for?
- Speeding up CPU-bound loops over large collections in Rust applications. Parallelizing data transformations such as map, filter, and sum over slices or vectors. Building custom task-parallel workloads with join, scope, or dedicated thread pools. Running Rust code with multithreading in the browser via wasm-bindgen-rayon.
- How do I install rayon?
- Add Rayon to your Cargo.toml dependencies: [dependencies] rayon = "1.12" Bring the parallel iterator traits into scope in each module: use rayon::prelude::*; Change foo.iter() to foo.par_iter() to run the iterator in parallel
- Where can I get rayon?
- The source code and installation instructions are on GitHub: https://github.com/rayon-rs/rayon
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Node.js worker thread pool for running CPU-heavy tasks off the main event loop, with queues, cancellation and run-time stats.
A header-only C++ library for writing task-parallel programs using task graphs, with CPU multithreading and CUDA GPU support.
A PyTorch-based distributed training and inference system for large AI models, offering parallelism, memory optimization and heterogeneous training.
A pure-Python utility library of 230+ extra constructs that extend the standard library, with no dependencies.
A PyTorch inference engine for Diffusion Transformers (DiTs) that adds caching, parallelism, quantization and CPU offload on top of Diffusers.