Merge branch 'ring_buffer_fix' into 'main'

fix: Stable & Predictable 64-byte

See merge request citron/emulator!90
This commit is contained in:
Zephyron
2025-10-07 15:47:34 +10:00

View File

@@ -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<T, capacity> m_data;
};