]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/segment_cleaner: refine metrics
authorYingxin Cheng <yingxin.cheng@intel.com>
Sat, 7 May 2022 08:00:22 +0000 (16:00 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 13 May 2022 07:51:20 +0000 (15:51 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/segment_cleaner.cc
src/crimson/os/seastore/segment_cleaner.h

index cf087c69a05348550b963d62ddece48037a1297b..ae3535f2d633d1b9a5be42283c06b2c4dd0ace35 100644 (file)
@@ -465,17 +465,31 @@ void SegmentCleaner::register_metrics()
     sm::make_counter("unavailable_unused_bytes",
                     [this] { return get_unavailable_unused_bytes(); },
                     sm::description("the size of the space is unavailable and not alive")),
-    sm::make_counter("projected_used_bytes", stats.projected_used_bytes,
-                    sm::description("the size of the space going to be occupied by new extents")),
 
-    sm::make_counter("accumulated_blocked_ios", stats.accumulated_blocked_ios,
-                    sm::description("accumulated total number of ios that were blocked by gc")),
-    sm::make_counter("reclaim_rewrite_bytes", stats.reclaim_rewrite_bytes,
+    sm::make_counter("projected_count", stats.projected_count,
+                   sm::description("the number of projected usage reservations")),
+    sm::make_counter("projected_used_bytes_sum", stats.projected_used_bytes_sum,
+                   sm::description("the sum of the projected usage in bytes")),
+
+    sm::make_counter("io_count", stats.io_count,
+                   sm::description("the sum of IOs")),
+    sm::make_counter("io_blocked_count", stats.io_blocked_count,
+                   sm::description("IOs that are blocked by gc")),
+    sm::make_counter("io_blocked_sum", stats.io_blocked_sum,
+                    sm::description("the sum of blocking IOs")),
+
+    sm::make_counter("reclaimed_bytes", stats.reclaimed_bytes,
+                    sm::description("rewritten bytes due to reclaim")),
+    sm::make_counter("reclaimed_segment_bytes", stats.reclaimed_segment_bytes,
                     sm::description("rewritten bytes due to reclaim")),
-    sm::make_counter("reclaiming_bytes", stats.reclaiming_bytes,
-                    sm::description("bytes being reclaimed")),
-    sm::make_counter("ios_blocking", stats.ios_blocking,
-                    sm::description("IOs that are blocking on space usage")),
+
+    sm::make_gauge("available_ratio",
+                   [this] { return segments.get_available_ratio(); },
+                   sm::description("ratio of available space to total space")),
+    sm::make_gauge("reclaim_ratio",
+                   [this] { return get_reclaim_ratio(); },
+                   sm::description("ratio of reclaimable space to unavailable space")),
+
     sm::make_histogram("segment_utilization_distribution",
                       [this]() -> seastar::metrics::histogram& {
                         return stats.segment_util;
@@ -911,7 +925,8 @@ SegmentCleaner::gc_reclaim_space_ret SegmentCleaner::gc_reclaim_space()
       auto d = seastar::lowres_system_clock::now() - start;
       INFO("duration: {}, pavail_ratio before: {}, repeats: {}", d, pavail_ratio, runs);
       if (final_reclaim()) {
-       stats.reclaim_rewrite_bytes += stats.reclaiming_bytes;
+       stats.reclaimed_bytes += stats.reclaiming_bytes;
+       stats.reclaimed_segment_bytes += segments.get_segment_size();
        stats.reclaiming_bytes = 0;
        next_reclaim_pos.reset();
       } else {
index 09b8aebfd2b9a826f89ce72c62116136b0c0ebce..6979d9d38d2b31e216286f0d23dcff3f533b3bb5 100644 (file)
@@ -635,18 +635,26 @@ private:
      * Bytes occupied by live extents
      */
     uint64_t used_bytes = 0;
+
     /**
      * projected_used_bytes
      *
      * Sum of projected bytes used by each transaction between throttle
-     * acquisition and commit completion.  See await_throttle()
+     * acquisition and commit completion.  See reserve_projected_usage()
      */
     uint64_t projected_used_bytes = 0;
+    uint64_t projected_count = 0;
+    uint64_t projected_used_bytes_sum = 0;
+
+    uint64_t io_blocking_num = 0;
+    uint64_t io_count = 0;
+    uint64_t io_blocked_count = 0;
+    uint64_t io_blocked_sum = 0;
 
-    uint64_t accumulated_blocked_ios = 0;
-    int64_t ios_blocking = 0;
-    uint64_t reclaim_rewrite_bytes = 0;
     uint64_t reclaiming_bytes = 0;
+    uint64_t reclaimed_bytes = 0;
+    uint64_t reclaimed_segment_bytes = 0;
+
     seastar::metrics::histogram segment_util;
   } stats;
   seastar::metrics::metric_group metrics;
@@ -1168,22 +1176,32 @@ public:
     // The pipeline configuration prevents another IO from entering
     // prepare until the prior one exits and clears this.
     ceph_assert(!blocked_io_wake);
-    stats.ios_blocking++;
+    bool is_blocked = false;
+    ++stats.io_count;
+    if (should_block_on_gc()) {
+      ++stats.io_blocking_num;
+      ++stats.io_blocked_count;
+      stats.io_blocked_sum += stats.io_blocking_num;
+      is_blocked = true;
+    }
     return seastar::do_until(
       [this] {
        log_gc_state("await_hard_limits");
        return !should_block_on_gc();
       },
       [this] {
-       stats.accumulated_blocked_ios++;
        blocked_io_wake = seastar::promise<>();
        return blocked_io_wake->get_future();
       }
-    ).then([this, projected_usage] {
+    ).then([this, projected_usage, is_blocked] {
       ceph_assert(!blocked_io_wake);
-      assert(stats.ios_blocking > 0);
-      stats.ios_blocking--;
       stats.projected_used_bytes += projected_usage;
+      ++stats.projected_count;
+      stats.projected_used_bytes_sum += stats.projected_used_bytes;
+      if (is_blocked) {
+        assert(stats.io_blocking_num > 0);
+        --stats.io_blocking_num;
+      }
     });
   }