Uses 128 bytes padding to prevent false-sharing #191
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to Intel Optimisation Manual, using 128 bytes is safer due to the spatial prefetcher - which can bring 2 cache-lines into L2.
see
Intel Netburst is pretty old but I've observed something similar with AMD Ryzen with multi-NUMA nodes.
See https://morestina.net/blog/1976/a-close-encounter-with-false-sharing as well
I've been hit by the same in Hyperfoil too, see https://github.com/Hyperfoil/Hyperfoil/pull/374/files#diff-03478637fd75a5eb1aef7f5db3b19db102359afba797e0328580dcc83796b735R40
OpenJDK itself seems to prefer 128 bytes: https://github.com/openjdk/jdk/blob/44024826e52373d1613ec366e3f5a9d5bbaefa41/src/hotspot/share/runtime/globals.hpp#L811
and fallback to the cache line only if the cache line exceed the configured default one, see https://github.com/openjdk/jdk/blob/44024826e52373d1613ec366e3f5a9d5bbaefa41/src/hotspot/cpu/x86/vm_version_x86.cpp#L1940-L1942