Skip to content

False Sharing

Spicy — senior dev territoryBackend

ELI5 - The Vibe Check

False sharing is a performance bug where two threads aren't even touching the same variable, but because those variables happen to live on the same cache line, every write from one thread invalidates the other thread's cached copy anyway. The CPUs end up fighting over a shared cache line for data they never actually share, and your parallel code quietly runs like it's single-threaded.

Real Talk

False sharing occurs when independent variables used by different threads happen to reside on the same CPU cache line, causing the cache coherence protocol to invalidate and re-fetch the line on every write from either thread even though no data is logically shared. It manifests as unexplained slowdowns in multi-threaded code that disappear once the variables are padded onto separate cache lines.

When You'll Hear This

"The counters were logically independent but false sharing made them serialize anyway." / "We padded the struct to 64 bytes per field and the throughput doubled."

Made with passive-aggressive love by manoga.digital. Powered by Claude.