From add9a52fcd011494f2cc84adfc2828753c227651 Mon Sep 17 00:00:00 2001 From: collecting Date: Tue, 7 Oct 2025 05:37:38 +0000 Subject: [PATCH] fix: Stable & Predictable 64-byte --- src/common/ring_buffer.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/common/ring_buffer.h b/src/common/ring_buffer.h index b92db6185..a0f8d4147 100644 --- a/src/common/ring_buffer.h +++ b/src/common/ring_buffer.h @@ -100,17 +100,11 @@ public: } private: - // It is important to align the below variables for performance reasons: - // Having them on the same cache-line would result in false-sharing between them. - // TODO: Remove this ifdef whenever clang and GCC support - // std::hardware_destructive_interference_size. -#ifdef __cpp_lib_hardware_interference_size - alignas(std::hardware_destructive_interference_size) std::atomic_size_t m_read_index{0}; - alignas(std::hardware_destructive_interference_size) std::atomic_size_t m_write_index{0}; -#else - alignas(128) std::atomic_size_t m_read_index{0}; - alignas(128) std::atomic_size_t m_write_index{0}; -#endif +// Use a fixed cache-line size of 64 bytes to prevent false sharing. This avoids +// [-Winterference-size] warnings by providing a stable ABI. 64 is a common +// value for modern CPUs. +alignas(64) std::atomic_size_t m_read_index{0}; +alignas(64) std::atomic_size_t m_write_index{0}; std::array m_data; };