From: Xuehan Xu Date: Mon, 11 May 2026 06:27:25 +0000 (+0800) Subject: crimson/os/seastore/cache: count promote/demote related metrics X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4dfa12ebc7c272dc71bfc4daaa8b1ab0935609c9;p=ceph-ci.git crimson/os/seastore/cache: count promote/demote related metrics Signed-off-by: Xuehan Xu --- diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 4608a5f8474..1146c994362 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -121,6 +121,8 @@ void Cache::register_metrics(store_index_t store_index) last_dirty_io_by_src_ext = {}; last_trim_rewrites = {}; last_reclaim_rewrites = {}; + last_promote_rewrites = {};; + last_demote_rewrites = {}; last_access = {}; last_cache_absent_by_src = {}; last_access_by_src_ext = {}; @@ -762,6 +764,34 @@ void Cache::register_metrics(store_index_t store_index) sm::description("sum of the version from rewrite-reclaim extents"), {sm::label_instance("shard_store_index", std::to_string(store_index))} ), + sm::make_counter( + "version_count_promote", + [this] { + return stats.promote_rewrites.get_num_rewrites(); + }, + sm::description("total number of rewrite-promote extents"), + {sm::label_instance("shard_store_index", std::to_string(store_index))} + ), + sm::make_counter( + "version_sum_promote", + stats.promote_rewrites.dirty_version, + sm::description("sum of the version from rewrite-promote extents"), + {sm::label_instance("shard_store_index", std::to_string(store_index))} + ), + sm::make_counter( + "version_count_demote", + [this] { + return stats.demote_rewrites.get_num_rewrites(); + }, + sm::description("total number of rewrite-demote extents"), + {sm::label_instance("shard_store_index", std::to_string(store_index))} + ), + sm::make_counter( + "version_sum_demote", + stats.demote_rewrites.dirty_version, + sm::description("sum of the version from rewrite-demote extents"), + {sm::label_instance("shard_store_index", std::to_string(store_index))} + ), } ); } @@ -1972,6 +2002,10 @@ record_t Cache::prepare_record( } else if (trans_src == Transaction::src_t::CLEANER_MAIN || trans_src == Transaction::src_t::CLEANER_COLD) { stats.reclaim_rewrites.add(rewrite_stats); + } else if (trans_src == Transaction::src_t::PROMOTE) { + stats.promote_rewrites.add(rewrite_stats); + } else if (trans_src == Transaction::src_t::DEMOTE) { + stats.demote_rewrites.add(rewrite_stats); } else { assert(rewrite_stats.is_clear()); } @@ -2871,6 +2905,10 @@ cache_stats_t Cache::get_stats( _trim_rewrites.minus(last_trim_rewrites); rewrite_stats_t _reclaim_rewrites = stats.reclaim_rewrites; _reclaim_rewrites.minus(last_reclaim_rewrites); + rewrite_stats_t _promote_rewrites = stats.promote_rewrites; + _promote_rewrites.minus(last_promote_rewrites); + rewrite_stats_t _demote_rewrites = stats.demote_rewrites; + _demote_rewrites.minus(last_demote_rewrites); oss << "\nrewrite trim ndirty=" << fmt::format(dfmt, _trim_rewrites.num_n_dirty/seconds) << "ps, dirty=" @@ -2882,7 +2920,19 @@ cache_stats_t Cache::get_stats( << "ps, dirty=" << fmt::format(dfmt, _reclaim_rewrites.num_dirty/seconds) << "ps, dversion=" - << fmt::format(dfmt, _reclaim_rewrites.get_avg_version()); + << fmt::format(dfmt, _reclaim_rewrites.get_avg_version()) + << "; promote ndirty=" + << fmt::format(dfmt, _promote_rewrites.num_n_dirty/seconds) + << "ps, dirty=" + << fmt::format(dfmt, _promote_rewrites.num_dirty/seconds) + << "ps, dversion=" + << fmt::format(dfmt, _promote_rewrites.get_avg_version()) + << "; demote ndirty=" + << fmt::format(dfmt, _demote_rewrites.num_n_dirty/seconds) + << "ps, dirty=" + << fmt::format(dfmt, _demote_rewrites.num_dirty/seconds) + << "ps, dversion=" + << fmt::format(dfmt, _demote_rewrites.get_avg_version()); oss << "\ncache total" << cache_size_stats_t{extents_index.get_bytes(), extents_index.size()}; @@ -2941,6 +2991,8 @@ cache_stats_t Cache::get_stats( last_dirty_io_by_src_ext = stats.dirty_io_by_src_ext; last_trim_rewrites = stats.trim_rewrites; last_reclaim_rewrites = stats.reclaim_rewrites; + last_promote_rewrites = stats.promote_rewrites; + last_demote_rewrites = stats.demote_rewrites; last_cache_absent_by_src = stats.cache_absent_by_src; last_access_by_src_ext = stats.access_by_src_ext; } diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index a413c76d066..7961cd8ba0e 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -1903,6 +1903,8 @@ private: rewrite_stats_t trim_rewrites; rewrite_stats_t reclaim_rewrites; + rewrite_stats_t promote_rewrites; + rewrite_stats_t demote_rewrites; } stats; mutable dirty_io_stats_t last_dirty_io; @@ -1910,6 +1912,8 @@ private: last_dirty_io_by_src_ext; mutable rewrite_stats_t last_trim_rewrites; mutable rewrite_stats_t last_reclaim_rewrites; + mutable rewrite_stats_t last_promote_rewrites; + mutable rewrite_stats_t last_demote_rewrites; mutable cache_access_stats_t last_access; mutable counter_by_src_t last_cache_absent_by_src; mutable counter_by_src_t >