concurrencyperformancecontention

Arc<RwLock<T>> as the default shared-state container

Reaching for Arc<RwLock<T>> for read-mostly state when arc-swap or atomics fit.

Why this looks tempting

RwLock allows many readers — feels like a free upgrade over Mutex.

Why wrong

RwLock still needs reader bookkeeping; under contention writers starve, readers queue, and acquisition is not free even on the fast path. For read-mostly snapshots, a lock is the wrong shape — you want to swap a pointer atomically, not coordinate.

Fix

For "publish a new value, all readers see it without blocking," use arc-swap's ArcSwap<T> or crossbeam::epoch. For numeric counters use AtomicU64. Keep RwLock for genuine read/write coordination over compound state.

Canonical alternative

concurrency/lock-free