rayon-rs/rayon
Rayon: A data parallelism library for Rust
Healthy across all four use cases
weakest axisPermissive license, no critical CVEs, actively maintained — safe to depend on.
Has a license, tests, and CI — clean foundation to fork and modify.
Documented and popular — useful reference codebase to read through.
No critical CVEs, sane security posture — runnable as-is.
- ✓Last commit 2w ago
- ✓6 active contributors
- ✓Apache-2.0 licensed
Show all 6 evidence items →Show less
- ✓CI configured
- ✓Tests present
- ⚠Single-maintainer risk — top contributor 92% of recent commits
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Healthy" badge
Paste into your README — live-updates from the latest cached analysis.
[](https://repopilot.app/r/rayon-rs/rayon)Paste at the top of your README.md — renders inline like a shields.io badge.
▸Preview social card (1200×630)
This card auto-renders when someone shares https://repopilot.app/r/rayon-rs/rayon on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: rayon-rs/rayon
Generated by RepoPilot · 2026-05-09 · Source
🤖Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding. - Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/rayon-rs/rayon shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
🎯Verdict
GO — Healthy across all four use cases
- Last commit 2w ago
- 6 active contributors
- Apache-2.0 licensed
- CI configured
- Tests present
- ⚠ Single-maintainer risk — top contributor 92% of recent commits
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
✅Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live rayon-rs/rayon
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale — regenerate it at
repopilot.app/r/rayon-rs/rayon.
What it runs against: a local clone of rayon-rs/rayon — the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in rayon-rs/rayon | Confirms the artifact applies here, not a fork |
| 2 | License is still Apache-2.0 | Catches relicense before you depend on it |
| 3 | Default branch main exists | Catches branch renames |
| 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code |
| 5 | Last commit ≤ 44 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of rayon-rs/rayon. If you don't
# have one yet, run these first:
#
# git clone https://github.com/rayon-rs/rayon.git
# cd rayon
#
# Then paste this script. Every check is read-only — no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of rayon-rs/rayon and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "rayon-rs/rayon(\\.git)?\\b" \\
&& ok "origin remote is rayon-rs/rayon" \\
|| miss "origin remote is not rayon-rs/rayon (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(Apache-2\\.0)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"Apache-2\\.0\"" package.json 2>/dev/null) \\
&& ok "license is Apache-2.0" \\
|| miss "license drift — was Apache-2.0 at generation time"
# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
&& ok "default branch main exists" \\
|| miss "default branch main no longer exists"
# 4. Critical files exist
test -f "rayon-core/src/lib.rs" \\
&& ok "rayon-core/src/lib.rs" \\
|| miss "missing critical file: rayon-core/src/lib.rs"
test -f "rayon-core/src/thread_pool/mod.rs" \\
&& ok "rayon-core/src/thread_pool/mod.rs" \\
|| miss "missing critical file: rayon-core/src/thread_pool/mod.rs"
test -f "rayon-core/src/join/mod.rs" \\
&& ok "rayon-core/src/join/mod.rs" \\
|| miss "missing critical file: rayon-core/src/join/mod.rs"
test -f "rayon-core/src/scope/mod.rs" \\
&& ok "rayon-core/src/scope/mod.rs" \\
|| miss "missing critical file: rayon-core/src/scope/mod.rs"
test -f "rayon-core/src/registry.rs" \\
&& ok "rayon-core/src/registry.rs" \\
|| miss "missing critical file: rayon-core/src/registry.rs"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 44 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~14d)"
else
miss "last commit was $days_since_last days ago — artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) — safe to trust"
else
echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/rayon-rs/rayon"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
⚡TL;DR
Rayon is a data-parallelism library for Rust that converts sequential iterators and computations into parallel ones with automatic work-stealing task distribution. It guarantees data-race freedom at compile time and makes parallelization as simple as changing iter() to par_iter() or using rayon::join() and rayon::scope() functions for custom task spawning. Monorepo structure: rayon/ is the public API facade with parallel iterators; rayon-core/ (path dependency in Cargo.toml) implements the thread-pool runtime, work-stealing scheduler, and synchronization primitives (latch.rs, join/mod.rs, scope/mod.rs, broadcast/mod.rs). CI includes ci/alt-core/ and ci/highlander/ test harnesses for alternative configurations.
👥Who it's for
Rust developers building compute-intensive applications (data processing, scientific computing, game engines) who need to leverage multi-core CPUs without managing threads directly or risking data races. Contributors are typically Rust systems programmers interested in concurrency and performance optimization.
🌱Maturity & risk
Production-ready and actively maintained. Version 1.12.0+ with comprehensive test suites across rayon-core/src/*/test.rs, CI pipelines (.github/workflows/), and minimum Rust 1.85 requirement indicate stable, modern tooling. Active dependency updates (Cargo.toml workspace dependencies) and recent release notes (RELEASES.md) show ongoing development.
Low risk for well-maintained dependencies (crossbeam-deque 0.8.1, either 1.x, libc 0.2) but depends critically on rayon-core which is a path dependency. Workspace lints enforce strict safety (unsafe-op-in-unsafe-fn deny, private-bounds deny) reducing correctness risk. Monitor rayon-rs/rayon GitHub for any breaking changes in major versions.
Active areas of work
Active maintenance on v1.12.0 with workspace linting enforcement (unreachable-pub, private-bounds denial) and Rust 1.85 MSRV. GitHub Actions pipelines (main.yaml, pr.yaml, ci.yaml) run on every PR. Feature development on web_spin_lock for wasm32-unknown-unknown target and spin-lock atomics alternatives visible in Cargo.toml.
🚀Get running
git clone https://github.com/rayon-rs/rayon.git
cd rayon
cargo test --all
cargo doc --open
Daily commands:
This is a library, not an executable. Run examples with cargo run --example <name> if rayon-demo exists, or write a test: cargo test --lib rayon::prelude to verify parallel iterator functionality.
🗺️Map of the codebase
rayon-core/src/lib.rs— Core entry point exporting thread pool, scopes, and parallelism primitives that every contributor must understand.rayon-core/src/thread_pool/mod.rs— Implements the global thread pool and work-stealing scheduler that is the foundation of all parallelism.rayon-core/src/join/mod.rs— Implements the core join operation that splits work into parallel subtasks—the most frequently used parallel primitive.rayon-core/src/scope/mod.rs— Implements scoped parallelism allowing references to be shared safely across parallel tasks.rayon-core/src/registry.rs— Manages thread-local worker state and registry access, critical for work-stealing coordination.rayon-core/src/job.rs— Defines the Job trait and work queue abstractions that enable the work-stealing scheduling algorithm.rayon-core/src/latch.rs— Implements latches for synchronization between parallel tasks—essential for join and scope semantics.
🛠️How to make changes
Add a New Parallel Primitive
- Define the public API function in rayon-core/src/lib.rs that exposes the new primitive (
rayon-core/src/lib.rs) - Implement the core logic in a new module under rayon-core/src/, following the Job trait pattern for work-stealing integration (
rayon-core/src/your_primitive/mod.rs) - Use the registry to access the thread pool via ThreadLocalRegistry::current(), and latch.rs for synchronization if needed (
rayon-core/src/registry.rs) - Add unit tests in your module's test.rs file and integration tests in rayon-core/tests/ (
rayon-core/tests/your_primitive.rs) - Add compile-fail tests in rayon-core/src/compile_fail/ to ensure memory safety guarantees (
rayon-core/src/compile_fail/your_primitive.rs)
Add Platform-Specific Synchronization (e.g., WASM)
- Update rayon-core/Cargo.toml to define a new feature flag (e.g., web_spin_lock) (
rayon-core/Cargo.toml) - Modify rayon-core/build.rs to detect the target platform and enable feature flags conditionally (
rayon-core/build.rs) - Implement platform-specific latch or synchronization in rayon-core/src/latch.rs with conditional compilation blocks (
rayon-core/src/latch.rs) - Add integration tests in rayon-core/tests/ that validate behavior on the target platform (
rayon-core/tests/use_current_thread.rs)
Optimize Worker Thread Scheduling
- Review the current sleep/wake policy in rayon-core/src/sleep/mod.rs which manages idle threads (
rayon-core/src/sleep/mod.rs) - Modify rayon-core/src/thread_pool/mod.rs to adjust thread spawning or work distribution logic (
rayon-core/src/thread_pool/mod.rs) - Update the work-stealing job queue in rayon-core/src/job.rs if changing task submission or dequeuing (
rayon-core/src/job.rs) - Add benchmarks using rayon-demo/src/ examples (e.g., quicksort, mergesort) to validate performance improvements (
rayon-demo/src/quicksort/bench.rs)
🔧Why these technologies
- Work-stealing scheduler (rayon-core/src/job.rs + thread_pool/mod.rs) — Provides load balancing across heterogeneous workloads with minimal synchronization overhead; threads steal work from others when idle.
- Rust ownership & lifetimes (scope.rs) — Enforces memory safety and data-race freedom at compile time without runtime checks; scoped parallelism prevents use-after-free across parallel tasks.
- Latches (latch.rs) for synchronization — Lightweight counting-based barriers for coordinating task completion; more efficient than Mutex for parallel work coordination.
- Thread-local registry (registry.rs) — Allows workers to access shared thread pool state and work queues with minimal contention; critical for work-stealing efficiency.
- Conditional compilation for WASM (build.rs, web_spin_lock feature) — WASM forbids atomics.wait on the main thread; feature flag enables spin-lock fallback for browser compatibility.
⚖️Trade-offs already made
-
Global thread pool vs. thread-pool-per-task
- Why: Single global pool reduces thread creation overhead and enables efficient work stealing across all tasks.
- Consequence: Users cannot isolate different workloads on separate pools; all parallelism shares one resource pool.
-
Scoped parallelism (scope.rs) vs. futures-based async
- Why: Scoped model provides deterministic synchronization and easier borrow-checker integration; simpler mental model for data parallelism.
- Consequence: Tasks must complete within scope lifetime; no long-lived async tasks. Not suitable for I/O-bound async workloads.
-
Work-stealing with latch-based synchronization
- Why: Minimizes synchronization primitives and allows efficient task distribution without explicit scheduling.
- Consequence: Higher complexity in scheduler implementation; potential for subtle race conditions if synchronization logic is incorrect.
-
Panic unwinding coordination (unwind.rs)
- Why: Ensures one panicking task terminates entire join/scope to prevent data races on panicked memory.
- Consequence: One panicked task kills all parallel work in that scope; less granular error recovery than explicit Result patterns.
🚫Non-goals (don't propose these)
- Does not provide actor-based concurrency or message-passing (use crossbeam or tokio for that).
- Does not support async/await or I/O-bound parallelism (designed for CPU-bound data parallelism).
- Does not expose manual work-queue manipulation or custom scheduling policies.
- Not a replacement for std::thread; focuses on data-parallel patterns, not general multithreading.
- Does not provide distributed parallelism across multiple machines.
🪤Traps & gotchas
WASM support is non-default: web_spin_lock feature must be enabled on wasm32-unknown-unknown because atomics.wait() is forbidden on browser main thread. Rayon-core is a path dependency (not published independently for end users), so local edits to rayon-core/ affect rayon immediately. Unsafe code in latch.rs and registry.rs requires careful review due to atomic orderings and lifetime safety (lints will catch unsafe-op-in-unsafe-fn violations). Compile-fail tests in rayon-core/src/compile_fail/ are intentionally invalid Rust and will not compile; do not try to fix them.
🏗️Architecture
💡Concepts to learn
- Work-stealing scheduler — Rayon's core performance mechanism; understanding how worker threads steal tasks from each other's queues (implemented in registry.rs and latch.rs) is essential to grasp why dynamic load balancing works
- Data-race freedom via type system — Rayon's key safety guarantee relies on Rust's Send/Sync traits and lifetime rules; scope/mod.rs enforces this at compile time to prevent data races without runtime checks
- Latches and synchronization barriers — latch.rs implements cross-thread coordination primitives (spin-loop latches) that allow tasks to wait for completion; critical for join() semantics
- Divide-and-conquer parallelism — Rayon's join() and recursive iterator splits follow divide-and-conquer; understanding task granularity trade-offs is essential for writing efficient parallel code
- Thread-local storage and TLS — Rayon uses scoped-tls crate (workspace dependency) and thread-local worker state in registry.rs to avoid global locks; understanding TLS tradeoffs (cache locality vs initialization overhead) is important
- Memory ordering and atomics — rayon-core uses atomic operations throughout (especially in latch.rs and registry.rs) with specific memory orderings (Relaxed, Release, Acquire); correctness depends on understanding happens-before relationships
- Iterator adapters and trait fusion — Rayon parallel iterators extend Rust's Iterator trait with par_iter(); understanding how rayon fuses operations (map + filter + reduce) into single parallel pass improves performance intuition
🔗Related repos
crossbeam-rs/crossbeam— Provides crossbeam-deque (work-stealing deque) and crossbeam-utils that rayon-core depends on for task queue and synchronizationtokio-rs/tokio— Alternative async runtime for Rust; rayon targets data-parallelism on CPUs while tokio targets I/O concurrency, often used togetherrayon-rs/rayon-demo— Official example codebase demonstrating rayon usage (listed in workspace members); reference for best practicesrust-lang/rust— Rayon leverages Rust's borrow checker and trait system for data-race freedom; tracking MSRV (1.85) requires monitoring Rust releasesrust-random/rand— Used in dev-dependencies for randomized testing in Rayon (particularly work-stealing scheduler verification)
🪄PR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add MIRI testing to CI for undefined behavior detection
Rayon is a concurrency library with significant unsafe code (rayon-core/src/job.rs, thread_pool/mod.rs, latch.rs). Currently, there's no MIRI (Miri - an interpreter for Rust's mid-level intermediate representation) testing in .github/workflows/. MIRI can detect undefined behavior in unsafe code blocks that regular tests miss. This would catch subtle concurrency bugs early and increase confidence in the unsafe code.
- [ ] Create a new GitHub Actions workflow file .github/workflows/miri.yaml
- [ ] Configure MIRI to run on rayon-core tests with MIRIFLAGS for detecting data races (e.g., -Zmiri-ignore-leaks)
- [ ] Test against rayon-core/tests/ and rayon-core/src/ unit tests
- [ ] Ensure workflow runs on pushes to main and all PRs
Add comprehensive threadpool stress tests for rayon-core/tests/
The existing tests in rayon-core/tests/ (double_init_fail.rs, simple_panic.rs, stack_overflow_crash.rs) cover specific edge cases but lack comprehensive stress tests for the thread pool under high contention. Looking at rayon-core/src/thread_pool/mod.rs and rayon-core/src/registry.rs, there are no tests for scenarios like: rapid task submission/completion cycles, varying workload distributions, or thread starvation conditions. This would increase confidence in production stability.
- [ ] Create rayon-core/tests/threadpool_stress.rs with tests for high-frequency task spawning
- [ ] Add test for uneven work distribution (some threads idle while others saturated)
- [ ] Add test for rapid thread pool initialization/teardown cycles
- [ ] Add benchmarking helper to measure latency under different contention levels
Document WASM target limitations in README and add wasm32-unknown-unknown tests to CI
The repo has a web_spin_lock feature for WASM (rayon/Cargo.toml) and mentions wasm32-unknown-unknown, but README.md doesn't document WASM support, limitations, or how to use the feature. Additionally, .github/workflows/ has no WASM-specific CI tests. Given that atomics.wait is forbidden on the browser main thread, this is a critical platform variant that should be tested.
- [ ] Add 'WASM Support' section to README.md documenting web_spin_lock feature and target requirements
- [ ] Create .github/workflows/wasm.yaml to test compilation and execution on wasm32-unknown-unknown target
- [ ] Add wasm-pack or similar tooling to test basic functionality on browser/WASI environments
- [ ] Document in README.md which rayon APIs are restricted/unsafe on WASM targets
🌿Good first issues
- Add integration tests for rayon-core/src/broadcast/ similar to rayon-core/src/join/test.rs pattern; broadcast/test.rs exists but could expand coverage for multi-threaded scenarios
- Document the work-stealing algorithm in rayon-core/README.md (none exists yet); explain how tasks move from one thread's deque to another's with code examples from registry.rs
- Expand rayon-core/src/sleep/README.md with concrete examples of thread-sleep backoff tuning; counters.rs logic is undocumented and could benefit from usage patterns
⭐Top contributors
Click to expand
Top contributors
- @cuviper — 92 commits
- @Daulox92 — 3 commits
- @paolobarbolini — 2 commits
- @c-git — 1 commits
- @hackerbirds — 1 commits
📝Recent commits
Click to expand
Recent commits
c4dac9f— Merge pull request #1300 from cuviper/try-infallible (cuviper)dc16a3d— Flatten infallible patterns into arguments (cuviper)ef20937— Merge pull request #1299 from cuviper/walk-tree-vec (cuviper)8582ad0— Usevec!to create walk-tree'sto_explore(cuviper)101822b— Merge pull request #1297 from cuviper/set-seq-cst (cuviper)e3e017d— Merge pull request #1298 from cuviper/ci-arches (cuviper)c04faa1— ci: add more aarch64 runners for tier-1 test coverage (cuviper)6b1367f— MakeCoreLatch::setuseSeqCstinstead ofAcqRel(cuviper)63349e4— Merge pull request #1296 from c-git/patch-1 (cuviper)708ce33— Fix typo in README regarding parallel iterators (c-git)
🔒Security observations
Rayon demonstrates a generally strong security posture with restrictive compiler linting for private bounds, private interfaces, and unsafe operations. However, there is a critical configuration error with an invalid Rust edition specification (2024) that must be corrected immediately. Dependencies appear well-maintained and pinned to stable versions. The library lacks a formal security disclosure policy. As a parallelism library handling concurrent operations, unsafe code is inherent to the design; the existing linting helps mitigate risks but continued vigilance on unsafe code audits is recommended.
- Medium · Outdated Rust Edition in Workspace Configuration —
Cargo.toml (workspace configuration). The workspace specifies edition = '2024', which is not a valid Rust edition. Valid editions are 2015, 2018, and 2021. This appears to be a typo and may cause build failures or unexpected behavior. The minimum rustc version is set to 1.85, but edition 2024 does not exist in that rustc version. Fix: Change 'edition = "2024"' to a valid edition such as '2021'. Verify withcargo checkthat the edition aligns with the minimum rustc version (1.85). - Low · Missing SECURITY.md or Security Policy —
Repository root. The repository does not appear to have a SECURITY.md file or documented security vulnerability disclosure process. This makes it difficult for security researchers to responsibly report vulnerabilities. Fix: Create a SECURITY.md file documenting how to responsibly report security vulnerabilities, or add a security policy via GitHub's security advisory feature. - Low · Broad Unsafe Code Linting Policy —
Cargo.toml (workspace.lints.rust). While the workspace enables 'unsafe-op-in-unsafe-fn' linting (which is good), this is a parallelism library that likely contains significant unsafe code. The current linting setup requires explicit unsafe blocks, but doesn't enforce documentation or additional scrutiny of unsafe operations. Fix: Consider adding additional documentation requirements for unsafe code blocks (e.g., via clippy rules). Regularly audit unsafe code sections in rayon-core, particularly in registry.rs, latch.rs, and thread pool implementations.
LLM-derived; treat as a starting point, not a security audit.
👉Where to read next
- Open issues — current backlog
- Recent PRs — what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.