]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: add metrics about hit/miss of ExtentPinboard
authorZhang Song <zhangsong02@qianxin.com>
Wed, 2 Jul 2025 10:28:58 +0000 (18:28 +0800)
committerZhang Song <zhangsong02@qianxin.com>
Fri, 18 Jul 2025 03:54:20 +0000 (11:54 +0800)
Signed-off-by: Zhang Song <zhangsong02@qianxin.com>
src/crimson/os/seastore/extent_pinboard.cc

index 8d8755e9eb2196f50f583640d192494f66dc3fe9..6c03eb5a19d6fbbd1f58042e77186d00b1dd51f9 100644 (file)
@@ -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<LogicalCachedExtent>();
@@ -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")
+      ),
     }
   );
 }