diff --git a/src/common/memory/MemoryTracker.h b/src/common/memory/MemoryTracker.h index 08b8ec7ad56..10022d0596d 100644 --- a/src/common/memory/MemoryTracker.h +++ b/src/common/memory/MemoryTracker.h @@ -11,6 +11,13 @@ namespace nebula { namespace memory { +constexpr size_t +#if defined(__cpp_lib_hardware_interference_size) + L1_CACHE_LINE_SIZE = hardware_destructive_interference_size; +#else + L1_CACHE_LINE_SIZE = 64; +#endif + // Memory stats for each thread. struct ThreadMemoryStats { ThreadMemoryStats(); @@ -114,7 +121,7 @@ class MemoryStats { private: // Global - int64_t limit_{std::numeric_limits::max()}; + alignas(L1_CACHE_LINE_SIZE) int64_t limit_{std::numeric_limits::max()}; std::atomic used_{0}; // Thread Local static thread_local ThreadMemoryStats threadMemoryStats_;