📖 Book · lowlatency · advanced

Cache lines & false sharing

Why two threads writing different variables can still stall each other — and how padding fixes it.

The 64-byte cache line as the unit of coherence, why false sharing silently destroys multithreaded scaling, a runnable that shows the layout difference between shared and alignas(64)-padded structs, and how to spot and fix it with padding and perf c2c.

3 chapters▶ runnable code✦ in-depth animation

What this book covers

  1. 01The cache line is the unit of sharing
  2. 02See the padding — run it
  3. 03Spotting and fixing it

Read it in full — runnable C++ + step-through animations

Every chapter of Cache lines & false sharing ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.