Definition (False Sharing)

Imagine two nodes (processor and/or machine) is trying to access some resource (page, file, etc.) from some caching mechanism (cache line, page). Suppose want data stored in resource . If is always writing to , to maintain memory coherence, some kind of atomic operation is done so that can write to without other nodes being able to read/write to it. However, if all wants to do is read, it has some extra overhead; it needs to wait for to finish writing.

This scenario is called false sharing, where one node is not actually sharing data with another node, but rather the resource granularity has enveloped both pieces of data.

Mitigation Strategies

  • Design the data schema so that variables accessed by different nodes are physically stored in different shards or pages.
  • Locality: move the computation to the data (or vice versa)
  • Looser consistency models
  • Padding (specifically for multiprocessor setups)