On this page
Date
2026-04-20
Read
2 min
Topic
rust
Tags
rust · concurrency
Memory ordering in practice (not the spec)
The Rust memory model docs are precise and cold. On a hot path you need a smaller question: what synchronization does this atomic actually guarantee?
This is part three of the lock-free series — after ABA/tagging and reclamation.
The three you use daily
Relaxed
owns: atomicity only
Cheapest. Don't use for publishing a pointer others will dereference.
Acquire / Release
owns: publish-subscribe
The default pattern for lock-free handoff.
SeqCst
owns: global order
Strongest, slowest. Reach for it when weaker orders fail and you need proof.
A handoff that works
handoff.rs
1data.write;2ready.store;34if ready.load 56
🦀
Ferris' hot tip
If you're mixing atomics and mutexes on the same data, stop — pick one story. Hybrid "mostly lock-free" code is where ordering bugs hide for months.
When to read the spec
Before you ship a general-purpose concurrent crate. Before you argue on Twitter.
For application queues and metrics, Acquire/Release + crossbeam gets you home.
Comments
Loading comments…