HARDWARE & CACHE • 8 MIN READ • January 20, 2025

Benchmarking Cache-Line Alignment in High-Frequency Orderbooks

Demonstrating how 64-byte atomic counter alignment eliminated false sharing between worker threads and saved 30% in L3 cache misses.

Prabhat Sharma Principal Systems Architect

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.

padded.rs
rust
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%.