Repolode
rayon-rs

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. 1

    Add Rayon to your Cargo.toml dependencies

    [dependencies] rayon = "1.12"
  2. 2

    Bring the parallel iterator traits into scope in each module

    use rayon::prelude::*;
  3. 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