From: Yingxin Cheng Date: Wed, 7 Jul 2021 01:45:33 +0000 (+0800) Subject: crimson/os/seastore/cache: count committed transactions X-Git-Tag: v17.1.0~1410^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=88f3b1ebd4a2dad7fc365cf776264b5a0d3723e9;p=ceph.git crimson/os/seastore/cache: count committed transactions Labeled by source. Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index d8bf3ff1388e..a9482f195fd4 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -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()); diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index b75c4d6097ae..897dc3d7ff38 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -574,6 +574,7 @@ private: struct { std::array trans_created_by_src; + std::array trans_committed_by_src; } stats; uint64_t& get_counter( std::array& counters_by_src,