]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool: only enable sharding for type_t::items in crimson 53130/head
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 6 Nov 2023 06:53:54 +0000 (14:53 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 23 Nov 2023 01:53:06 +0000 (09:53 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/common/mempool.cc
src/include/mempool.h

index 128a3d1a16ccc54d24f51edac2215b4bc294359f..4ecfaf81fc662f55a7aa87ca9abed800240e87e0 100644 (file)
@@ -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
     }
   }
 }
index 1091268e8554b09c51a8118ee3eed98005e1f865..a6dca48dd6fef43d5e2f9baadc8c0cbd5f0a6b52 100644 (file)
@@ -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<ssize_t> items = {0}; // signed
     char __padding[128 - sizeof(ceph::atomic<ssize_t>)];
   } __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<ssize_t> 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<T*>(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<char*>(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);
   }