]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: count committed transactions
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 7 Jul 2021 01:45:33 +0000 (09:45 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 14 Jul 2021 02:52:21 +0000 (10:52 +0800)
Labeled by source.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h

index d8bf3ff1388eb0ebf2bff6d250571438db9fb58b..a9482f195fd40585d627723e70d6928c72123a74 100644 (file)
@@ -137,6 +137,50 @@ void Cache::register_metrics()
       ),
     }
   );
+
+  /*
+   * trans_committed
+   */
+  stats.trans_committed_by_src.fill(0);
+  auto register_trans_committed = [this, &labels_by_src](src_t src) {
+    std::ostringstream oss_desc;
+    oss_desc << "total number of transaction committed (src="
+             << src << ")";
+    metrics.add_group(
+      "cache",
+      {
+        sm::make_counter(
+          "trans_committed",
+          get_counter(stats.trans_committed_by_src, src),
+          sm::description(oss_desc.str()),
+          {labels_by_src.find(src)->second}
+        ),
+      }
+    );
+  };
+  for (auto& src : {src_t::MUTATE,
+                    src_t::INIT,
+                    src_t::CLEANER}) {
+    register_trans_committed(src);
+  }
+
+  metrics.add_group(
+    "cache",
+    {
+      sm::make_counter(
+        "trans_committed",
+        [this] {
+          uint64_t total = 0;
+          for (auto& v : stats.trans_committed_by_src) {
+            total += v;
+          }
+          return total;
+        },
+        sm::description("total number of transaction committed"),
+        {src_label("ALL")}
+      ),
+    }
+  );
 }
 
 void Cache::add_extent(CachedExtentRef ref)
@@ -313,6 +357,10 @@ record_t Cache::prepare_record(Transaction &t)
   LOG_PREFIX(Cache::prepare_record);
   DEBUGT("enter", t);
 
+  assert(!t.is_weak());
+  assert(t.get_src() != Transaction::src_t::READ);
+  ++(get_counter(stats.trans_committed_by_src, t.get_src()));
+
   // Should be valid due to interruptible future
   for (auto &i: t.read_set) {
     assert(i.ref->is_valid());
index b75c4d6097ae296cca4f150d2957533549da4a86..897dc3d7ff3828349736fe04e40be38e03fac77e 100644 (file)
@@ -574,6 +574,7 @@ private:
 
   struct {
     std::array<uint64_t, Transaction::SRC_MAX> trans_created_by_src;
+    std::array<uint64_t, Transaction::SRC_MAX> trans_committed_by_src;
   } stats;
   uint64_t& get_counter(
       std::array<uint64_t, Transaction::SRC_MAX>& counters_by_src,