Outline updated November 2026
Rust Parallel Programming
Class Duration
14 hours of live training delivered over 2-4 days to accommodate your scheduling needs.
Student Prerequisites
- Working Rust experience equivalent to Mastering Rust, including traits, generics, and closures
- A solid understanding of ownership and borrowing
- Familiarity with threads and basic concurrency concepts in any language
- Memory-Safe Programming with Rust (smart pointers and interior mutability) or equivalent experience is helpful
Target Audience
- Systems programmers building high-performance applications
- Backend developers optimizing compute-intensive workloads
- Engineers migrating parallel C/C++ code to Rust
- Developers building real-time data processing pipelines
- Teams working on scientific computing or simulations
New to Rust? Start with Rust Essentials or Mastering Rust. Memory-Safe Programming with Rust is a good step before this course.
Description
This course teaches Rust developers to write correct, fast parallel and concurrent programs. It starts with Send, Sync, and scoped threads, then covers Rayon, channels, locks, and atomics. Later modules cover memory ordering, lock-free data structures, and async concurrency on Tokio. Students test concurrent code with Loom and Miri. They use the same tools to review AI-generated parallel code, where memory-ordering mistakes are common.
Learning Outcomes
- Choose threads, Rayon, or async for a given workload.
- Share data across threads with
Send,Sync, and scoped threads. - Parallelize CPU-bound work with Rayon and measure the speedup.
- Build channel pipelines with bounded queues and backpressure.
- Choose between locks, condition variables, and atomics.
- Apply memory orderings correctly.
- Explain the ABA problem and memory reclamation in lock-free code.
- Write async code on Tokio without blocking the runtime.
- Test concurrent code with Loom and Miri.
- Benchmark parallel code with Criterion.
- Catch data races hidden in AI-generated code.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples.
Software Requirements
A free GitHub account, the current stable Rust toolchain via rustup (2024 edition), a nightly toolchain with the Miri component (rustup +nightly component add miri), Visual Studio Code or another supported editor with the rust-analyzer extension, a machine with at least four CPU cores so parallel speedups are measurable, and an AI coding assistant of choice (GitHub Copilot, Cursor, or Claude Code). Linux or macOS is recommended for profiling with perf and flame graphs; Windows works for all other topics. A cloud-based environment can be provided if local installation is restricted.
Training Topics
Concurrency and Parallelism in Rust
- Concurrency vs. parallelism
- Amdahl's law and work granularity
- Threads, Rayon, or async
- How
SendandSyncprevent data races - Deadlocks, livelocks, and logic races
Threads and Shared State
- Spawning threads and
JoinHandle - Scoped threads with
std::thread::scope Arc,Mutex, andRwLock- Condition variables and barriers
OnceLockandLazyLock- Thread-local storage
- Lock poisoning and lock ordering
- Avoiding deadlocks
parking_lotlocks
Data Parallelism with Rayon
par_iter,par_iter_mut, andinto_par_iter- Converting sequential code
- Parallel
map,filter, andreduce - Parallel
foldandcollect - Parallel sorting with
par_sort par_bridgefor ordinary iterators- When not to parallelize
Thread Pools and Work Stealing
- How work stealing works
- Global and custom thread pools
joinandscopefor divide-and-conquer- Pool size and thread naming
- Rayon alongside async runtimes
Message Passing and Channels
std::sync::mpscchannels- Crossbeam MPMC channels
- Bounded and unbounded channels
- Crossbeam
select! - Backpressure with bounded queues
- Pipelines and fan-out/fan-in
- Tokio
mpsc,oneshot,broadcast, andwatch
Crossbeam Utilities
- The Crossbeam crates
- Work-stealing deques with
crossbeam-deque ArrayQueueandSegQueueBackoffandCachePadded- Epoch-based reclamation with
crossbeam-epoch
Atomics and Memory Ordering
AtomicBool,AtomicUsize, andAtomicPtrRelaxed,Acquire, andReleaseAcqRelandSeqCst- Happens-before and fences
- Compare-and-swap loops
- Why to avoid user-space spin locks
- False sharing and cache-line padding
- Atomics vs. locks
Lock-Free Data Structures
- Lock-free vs. wait-free
- A lock-free stack and queue
- The ABA problem
- Epochs, hazard pointers, and reference counting
- Using proven crates
Async Concurrency
- I/O-bound vs. CPU-bound work
- Tokio's multi-threaded scheduler
tokio::select!andJoinSet- Structured cancellation
- Async closures and async fn in traits
spawn_blockingand Rayon for CPU work- Async locks and semaphores
- Streams and
futures::Stream
Testing and Verifying Concurrent Code
- Why concurrency bugs escape tests
- Exploring interleavings with Loom
- Structuring code for Loom
- Finding undefined behavior with Miri
- ThreadSanitizer
- Stress and deterministic testing
- Benchmarking with Criterion
- Profiling with flame graphs
AI-Assisted Parallel Rust
- Where AI helps and where it hurts
- Prompts for memory-ordering questions
- Miri and Loom as the check
- Reflexive
Arc<Mutex<T>>in parallel code - AI-assisted refactors and code review