False sharing
False sharing is a performance problem in which independent data accessed by different threads occupy the same cache line, causing unnecessary cache-coherence traffic when that data is modified.
C++ Concurrency in Action, Second Edition
False sharing is a performance problem in which distinct data items accessed by different threads occupy the same cache line, causing unnecessary cache-line transfers.
- How it is used
- Guides data layout and thread assignment when designing multithreaded code for performance.
- How deep it goes
- Explains cache-line ownership transfers through repeated array updates, then gives spacing and work-partitioning remedies without prescribing a universal layout.
- Examples
- Uses per-thread array entries, row-versus-column matrix assignments, and a padded C++ structure.
- What you can do after
- Diagnose/debug with it by spotting cross-thread writes to one cache line, then regrouping work or spacing data apart.
Read how C++ Concurrency in Action, Second Edition explains false sharing →
100 Go Mistakes and How to Avoid Them
False sharing is a performance problem in which independent variables occupy the same cache line, causing updates by different cores to invalidate one another's cached data.
- How it is used
- Diagnoses a concurrency pattern that preserves correctness but degrades performance through cache-coherency traffic.
- How deep it goes
- Explains memory blocks, 64-byte cache lines, per-core L1D caches, invalidation, and padding, but stops short of benchmark results.
- Examples
- Demonstrates adjacent sumA and sumB accumulators, two updating goroutines, cache-line replication, and a padded Result struct.
- What you can do after
- Diagnose false sharing in concurrent updates and apply struct padding when independent fields contend through shared cache lines.
Read how 100 Go Mistakes and How to Avoid Them explains false sharing →
Also covered in
- The Coder CafeIn early access (MEAP)
What to know first
- cache lineA cache line is a fixed-size block of contiguous memory that a cache transfers or manages as a unit.
- performancePerformance is a measure of how effectively a person, process, model, or system achieves its objectives, including qualities such as output quality, speed, and resource efficiency.
Related concepts
- cache lineuses · A cache line is a fixed-size block of contiguous memory that a cache transfers or manages as a unit.
- bloom filterproduced by · A Bloom filter is a space-efficient probabilistic data structure for testing set membership that permits false positives but not false negatives.
- cache ping-pongproduces · Cache ping-pong is performance-degrading cache-coherence traffic caused by multiple threads repeatedly accessing the same shared data.
- performanceproduces · Performance is a measure of how effectively a person, process, model, or system achieves its objectives, including qualities such as output quality, speed, and resource efficiency.
Questions about false sharing
What is false sharing?
False sharing is a performance problem in which independent data accessed by different threads occupy the same cache line, causing unnecessary cache-coherence traffic when that data is modified.
Which Manning books explain false sharing?
C++ Concurrency in Action, Second Edition and 100 Go Mistakes and How to Avoid Them.
What should I know before learning false sharing?
Manning books that teach false sharing usually introduce cache line and performance first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

