]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: add op_lat histogram buckets
authorMatan Breizman <mbreizma@redhat.com>
Thu, 4 Jun 2026 09:39:06 +0000 (09:39 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 4 Jun 2026 09:39:06 +0000 (09:39 +0000)
Initialize lat_hist_bounds_us bucket boundaries (0.25ms–20ms in 10
log-ish steps) for the op_lat Seastar histogram in register_metrics(),
and populate them in add_latency_sample(). Previously op_lat only
tracked sample_count and sample_sum, giving an average but no
percentile visibility.

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h

index 68f0e310924db4c281493e7cd13f79c1c00d538e..f66fc9fd964ea2d318e50cacf99234179bc3bddb 100644 (file)
@@ -178,6 +178,14 @@ void SeaStore::Shard::register_metrics(store_index_t store_index)
     {op_type_t::OMAP_ITERATE,     sm::label_instance("latency", "OMAP_ITERATE")},
   };
 
+  for (auto& hist : stats.op_lat) {
+    hist.buckets.resize(lat_hist_bounds_us.size());
+    for (std::size_t i = 0; i < lat_hist_bounds_us.size(); ++i) {
+      hist.buckets[i].upper_bound = lat_hist_bounds_us[i];
+      hist.buckets[i].count = 0;
+    }
+  }
+
   for (auto& [op_type, label] : labels_by_op_type) {
     auto desc = fmt::format("latency of seastore operation (optype={})",
                             op_type);
index 4b356f4304a9c3d69543fab8611cdf631c5c76de..eae23b4525a58f8085bd85c88f81f7bd9394a8c6 100644 (file)
@@ -425,6 +425,19 @@ public:
 
     static constexpr auto LAT_MAX = static_cast<std::size_t>(op_type_t::MAX);
 
+    // Histogram bucket upper bounds in microseconds (0.25ms–20ms).
+    // Ops above 20ms land in the last bucket as overflow.
+    static constexpr std::array<double, 14> lat_hist_bounds_us = {
+      250, 500, 1000,
+      1500, 2000, 3000,
+      5000,
+      7500, 10000,
+      15000, 20000,
+      30000, 50000,
+      100000
+    };
+
+
     struct {
       std::array<seastar::metrics::histogram, LAT_MAX> op_lat;
     } stats;
@@ -440,6 +453,17 @@ public:
       seastar::metrics::histogram& lat = get_latency(op_type);
       lat.sample_count++;
       lat.sample_sum += std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
+      bool found = false;
+      for (auto& b : lat.buckets) {
+        if (static_cast<double>(std::chrono::duration_cast<std::chrono::microseconds>(dur).count()) <= b.upper_bound) {
+          ++b.count;
+          found = true;
+          break;
+        }
+      }
+      if (!found && !lat.buckets.empty()) {
+        ++lat.buckets.back().count;
+      }
     }
 
     /*