Why does false sharing still affect non atomics, but much less than atomics?
问题 Consider the following example that proves false sharing existence: using type = std::atomic<std::int64_t>; struct alignas(128) shared_t { type a; type b; } sh; struct not_shared_t { alignas(128) type a; alignas(128) type b; } not_sh; One thread increments a by steps of 1, another thread increments b . Increments compile to lock xadd with MSVC, even though the result is unused. For a structure where a and b are separated, the values accumulated in a few seconds is about ten times greater for