From 65fca0a9f474b3d63eb26410210ca4e77c0c810a Mon Sep 17 00:00:00 2001 From: Zhang Song Date: Wed, 2 Jul 2025 18:28:58 +0800 Subject: [PATCH] crimson/os/seastore: add metrics about hit/miss of ExtentPinboard Signed-off-by: Zhang Song --- src/crimson/os/seastore/extent_pinboard.cc | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/crimson/os/seastore/extent_pinboard.cc b/src/crimson/os/seastore/extent_pinboard.cc index 8d8755e9eb219..6c03eb5a19d6f 100644 --- a/src/crimson/os/seastore/extent_pinboard.cc +++ b/src/crimson/os/seastore/extent_pinboard.cc @@ -274,6 +274,10 @@ class ExtentPinboardLRU : public ExtentPinboard { ExtentQueue lru; seastar::metrics::metric_group metrics; + // hit and miss indicates if an extent is linked when touching it + uint64_t hit = 0; + uint64_t miss = 0; + public: ExtentPinboardLRU(std::size_t capacity) : lru(capacity) { LOG_PREFIX(ExtentPinboardLRU::ExtentPinboardLRU); @@ -311,6 +315,14 @@ public: }, sm::description("total extents pinned by the lru") ), + sm::make_counter( + "lru_hit", hit, + sm::description("total count of the extents that are linked to lru when touching them") + ), + sm::make_counter( + "lru_miss", miss, + sm::description("total count of the extents that are not linked to lru when touching them") + ), } ); } @@ -335,8 +347,10 @@ public: extent_len_t /*load_length*/) final { if (extent.is_linked_to_list()) { lru.move_to_top(extent, p_src); + hit++; } else { lru.add_to_top(extent, p_src); + miss++; } } @@ -531,6 +545,7 @@ public: // hot until it is evicted to the warm out queue and accessed once // again. } + hit++; } else if (!is_logical_type(extent.get_type())) { // put physical extents to hot queue directly ceph_assert(state == extent_2q_state_t::Fresh); @@ -538,6 +553,7 @@ public: auto trimmed_extents = hot.add_to_top(extent, p_src); on_update_hot(trimmed_extents); hit_queue(overall_hits.absent, p_src, type); + miss++; } else { // the logical extent which is not in warm_in and not in hot ceph_assert(state == extent_2q_state_t::Fresh); auto lext = extent.cast(); @@ -562,6 +578,7 @@ public: hit_queue(overall_hits.sequential_absent, p_src, type); } } + miss++; } auto end = load_start + load_length; assert(end != 0); @@ -695,6 +712,10 @@ private: }; mutable hit_stats_t overall_hits; mutable hit_stats_t last_hits; + + // hit and miss indicates if an extent is linked when touching it + uint64_t hit = 0; + uint64_t miss = 0; }; void ExtentPinboardTwoQ::get_stats( @@ -808,6 +829,14 @@ void ExtentPinboardTwoQ::register_metrics() { }, sm::description("total extents pinned by the 2q hot queue") ), + sm::make_counter( + "2q_hit", hit, + sm::description("total count of the extents that are linked to 2Q when touching them") + ), + sm::make_counter( + "2q_miss", miss, + sm::description("total count of the extents that are not linked to 2Q when touching them") + ), } ); } -- 2.39.5