libexpr: Replace hardcoded cache line size with std::hardware_destructive_interference_size
This expands to __GCC_DESTRUCTIVE_SIZE, which is also 64 (at least in the x86_64 stdenv). Let the compiler decide what's the appropriate cache line size is. Also, on aarch64-darwin the cache line size 128 bytes, so the previous fix didn't actually get rid of false sharing reliably. Clang does this [1] [2], so it overestimates the sizes somewhat, but that's still enough for avoiding false sharing on darwin. [1]:a289341ded/clang/lib/Frontend/InitPreprocessor.cpp (L1331-L1339)[2]:6f51f8e0f9/clang/lib/Basic/Targets/AArch64.h (L262-L264)
This commit is contained in:
@@ -25,6 +25,7 @@ add_project_arguments(
|
||||
'-Wignored-qualifiers',
|
||||
'-Wimplicit-fallthrough',
|
||||
'-Wno-deprecated-declarations',
|
||||
'-Wno-interference-size', # Used for C++ ABI only. We don't provide any guarantees about different march tunings.
|
||||
language : 'cpp',
|
||||
)
|
||||
|
||||
|
||||
@@ -318,7 +318,6 @@ EvalState::EvalState(
|
||||
countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0";
|
||||
|
||||
static_assert(sizeof(Env) <= 16, "environment must be <= 16 bytes");
|
||||
static_assert(sizeof(Counter) == 64, "counters must be 64 bytes");
|
||||
|
||||
/* Construct the Nix expression search path. */
|
||||
assert(lookupPath.elements.empty());
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace nix {
|
||||
* variable is set. This is to prevent contention on these counters
|
||||
* when multi-threaded evaluation is enabled.
|
||||
*/
|
||||
struct alignas(64) Counter
|
||||
struct alignas(std::hardware_destructive_interference_size) Counter
|
||||
{
|
||||
using value_type = uint64_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user