From ac50fd3a71288b22160f849efb4650d814f3847e Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 13 Jan 2016 14:51:58 -0800 Subject: [PATCH] Align statistics Use Yield macro to make it a little more portable between platforms. --- port/port_posix.h | 2 ++ port/win/port_win.h | 2 +- util/statistics.h | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/port/port_posix.h b/port/port_posix.h index efcd1aa8e..74c42f31b 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -16,6 +16,8 @@ // in fact, we could use that one #define ROCKSDB_PRIszt "zu" +#define __declspec(S) + #define ROCKSDB_NOEXCEPT noexcept #undef PLATFORM_IS_LITTLE_ENDIAN diff --git a/port/win/port_win.h b/port/win/port_win.h index 9ee7d96be..d901c40bf 100644 --- a/port/win/port_win.h +++ b/port/win/port_win.h @@ -245,7 +245,7 @@ extern void InitOnce(OnceType* once, void (*initializer)()); static inline void AsmVolatilePause() { #if defined(_M_IX86) || defined(_M_X64) - ::_mm_pause(); + YieldProcessor(); #endif // it would be nice to get "wfe" on ARM here } diff --git a/util/statistics.h b/util/statistics.h index 55914f59e..b42fb43a5 100644 --- a/util/statistics.h +++ b/util/statistics.h @@ -61,7 +61,13 @@ class StatisticsImpl : public Statistics { char padding[64 - sizeof(std::atomic_uint_fast64_t)]; }; - Ticker tickers_[INTERNAL_TICKER_ENUM_MAX] __attribute__((aligned(64))); + static_assert(sizeof(Ticker) == 64, "Expecting to fit into 64 bytes"); + + // Attributes expand to nothing depending on the platform + __declspec(align(64)) + Ticker tickers_[INTERNAL_TICKER_ENUM_MAX] + __attribute__((aligned(64))); + __declspec(align(64)) HistogramImpl histograms_[INTERNAL_HISTOGRAM_ENUM_MAX] __attribute__((aligned(64))); };