liveBook · Manning

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.

How 2 Manning books explain it

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

What to know first

Related concepts

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.