From 931894f0f6f6003f80d68151d742dc9f9380e249 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Mon, 6 Nov 2023 14:53:54 +0800 Subject: [PATCH] mempool: only enable sharding for type_t::items in crimson Signed-off-by: Yingxin Cheng --- src/common/mempool.cc | 5 +++++ src/include/mempool.h | 26 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/common/mempool.cc b/src/common/mempool.cc index 128a3d1a16c..4ecfaf81fc6 100644 --- a/src/common/mempool.cc +++ b/src/common/mempool.cc @@ -128,12 +128,17 @@ void mempool::pool_t::get_stats( for (auto &p : type_map) { std::string n = ceph_demangle(p.second.type_name); stats_t &s = (*by_type)[n]; +#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) s.bytes = 0; s.items = 0; for (size_t i = 0 ; i < num_shards; ++i) { s.bytes += p.second.shards[i].items * p.second.item_size; s.items += p.second.shards[i].items; } +#else + s.bytes = p.second.items * p.second.item_size; + s.items = p.second.items; +#endif } } } diff --git a/src/include/mempool.h b/src/include/mempool.h index 1091268e855..a6dca48dd6f 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -262,16 +262,20 @@ const char *get_pool_name(pool_index_t ix); struct type_t { const char *type_name; size_t item_size; +#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) struct type_shard_t { ceph::atomic items = {0}; // signed char __padding[128 - sizeof(ceph::atomic)]; } __attribute__ ((aligned (128))); + static_assert(sizeof(type_shard_t) == 128, + "type_shard_t should be cacheline-sized"); type_shard_t shards[num_shards]; +#else +// XXX: consider dropping this case for classic with perf tests + ceph::atomic items = {0}; // signed +#endif }; -static_assert(sizeof(type_t::type_shard_t) == 128, - "type_shard_t should be cacheline-sized"); - struct type_info_hash { std::size_t operator()(const std::type_info& k) const { return k.hash_code(); @@ -362,7 +366,11 @@ public: shard.bytes += total; shard.items += n; if (type) { +#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) type->shards[shid].items += n; +#else + type->items += n; +#endif } T* r = reinterpret_cast(new char[total]); return r; @@ -375,7 +383,11 @@ public: shard.bytes -= total; shard.items -= n; if (type) { +#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) type->shards[shid].items -= n; +#else + type->items -= n; +#endif } delete[] reinterpret_cast(p); } @@ -387,7 +399,11 @@ public: shard.bytes += total; shard.items += n; if (type) { +#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) type->shards[shid].items += n; +#else + type->items += n; +#endif } char *ptr; int rc = ::posix_memalign((void**)(void*)&ptr, align, total); @@ -404,7 +420,11 @@ public: shard.bytes -= total; shard.items -= n; if (type) { +#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) type->shards[shid].items -= n; +#else + type->items -= n; +#endif } aligned_free(p); } -- 2.39.5