The False Sharing Tax
Two atomic counters that live on the same 64-byte cache line will fight each other. Every write from core A invalidates the line in core B’s L1, even though the two cores touch logically unrelated data. On a hot orderbook this showed up as a flat 30% penalty in L3 misses.
use crossbeam_utils::CachePadded; struct BookCounters { // Each counter now owns a full cache line — no cross-core invalidation. bids: CachePadded<AtomicU64>, asks: CachePadded<AtomicU64>,}The Numbers
After padding the counters to CachePadded, Criterion reported a 1.9x throughput improvement on the contended path and L3 misses dropped from 14% to under 4%.