]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: cleanups to SeaStore::report_stats() 59553/head
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 2 Sep 2024 03:38:40 +0000 (11:38 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Mon, 2 Sep 2024 03:38:40 +0000 (11:38 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore_types.h

index e41de39fa72926841b162dbb19ddb66f356298e9..1577433237351d23e304af733ccda9f3306a8eff 100644 (file)
@@ -711,13 +711,9 @@ seastar::future<> SeaStore::report_stats()
     }
 
     cache_size_stats_t lru_sizes_ps = cache_total.lru_sizes;
-    lru_sizes_ps.size /= seastar::smp::count;
-    lru_sizes_ps.num_extents /= seastar::smp::count;
+    lru_sizes_ps.divide_by(seastar::smp::count);
     cache_io_stats_t lru_io_ps = cache_total.lru_io;
-    lru_io_ps.in_sizes.size /= seastar::smp::count;
-    lru_io_ps.in_sizes.num_extents /= seastar::smp::count;
-    lru_io_ps.out_sizes.size /= seastar::smp::count;
-    lru_io_ps.out_sizes.num_extents /= seastar::smp::count;
+    lru_io_ps.divide_by(seastar::smp::count);
     INFO("cache lru: total{} {}; per-shard: total{} {}",
          cache_total.lru_sizes,
          cache_io_stats_printer_t{seconds, cache_total.lru_io},
@@ -725,15 +721,9 @@ seastar::future<> SeaStore::report_stats()
          cache_io_stats_printer_t{seconds, lru_io_ps});
 
     cache_size_stats_t dirty_sizes_ps = cache_total.dirty_sizes;
-    dirty_sizes_ps.size /= seastar::smp::count;
-    dirty_sizes_ps.num_extents /= seastar::smp::count;
+    dirty_sizes_ps.divide_by(seastar::smp::count);
     dirty_io_stats_t dirty_io_ps = cache_total.dirty_io;
-    dirty_io_ps.in_sizes.size /= seastar::smp::count;
-    dirty_io_ps.in_sizes.num_extents /= seastar::smp::count;
-    dirty_io_ps.num_replace /= seastar::smp::count;
-    dirty_io_ps.out_sizes.size /= seastar::smp::count;
-    dirty_io_ps.out_sizes.num_extents /= seastar::smp::count;
-    dirty_io_ps.out_versions /= seastar::smp::count;
+    dirty_io_ps.divide_by(seastar::smp::count);
     INFO("cache dirty: total{} {}; per-shard: total{} {}",
          cache_total.dirty_sizes,
          dirty_io_stats_printer_t{seconds, cache_total.dirty_io},
@@ -741,14 +731,7 @@ seastar::future<> SeaStore::report_stats()
          dirty_io_stats_printer_t{seconds, dirty_io_ps});
 
     cache_access_stats_t access_ps = cache_total.access;
-    access_ps.cache_absent /= seastar::smp::count;
-    access_ps.s.trans_pending /= seastar::smp::count;
-    access_ps.s.trans_dirty /= seastar::smp::count;
-    access_ps.s.trans_lru /= seastar::smp::count;
-    access_ps.s.cache_dirty /= seastar::smp::count;
-    access_ps.s.cache_lru /= seastar::smp::count;
-    access_ps.s.load_absent /= seastar::smp::count;
-    access_ps.s.load_present /= seastar::smp::count;
+    access_ps.divide_by(seastar::smp::count);
     INFO("cache_access: total{}; per-shard{}",
          cache_access_stats_printer_t{seconds, cache_total.access},
          cache_access_stats_printer_t{seconds, access_ps});
index 62bb3e386359cb6c1c189691aafc2cbb3625bcd3..df5c184e7ab0c8a41dfd4c94f15b72e8fb79eb86 100644 (file)
@@ -2800,6 +2800,11 @@ struct cache_size_stats_t {
     size -= o.size;
     num_extents -= o.num_extents;
   }
+
+  void divide_by(unsigned d) {
+    size /= d;
+    num_extents /= d;
+  }
 };
 std::ostream& operator<<(std::ostream&, const cache_size_stats_t&);
 struct cache_size_stats_printer_t {
@@ -2825,6 +2830,11 @@ struct cache_io_stats_t {
     in_sizes.minus(o.in_sizes);
     out_sizes.minus(o.out_sizes);
   }
+
+  void divide_by(unsigned d) {
+    in_sizes.divide_by(d);
+    out_sizes.divide_by(d);
+  }
 };
 struct cache_io_stats_printer_t {
   double seconds;
@@ -2861,6 +2871,13 @@ struct dirty_io_stats_t {
     out_sizes.minus(o.out_sizes);
     out_versions -= o.out_versions;
   }
+
+  void divide_by(unsigned d) {
+    in_sizes.divide_by(d);
+    num_replace /= d;
+    out_sizes.divide_by(d);
+    out_versions /= d;
+  }
 };
 struct dirty_io_stats_printer_t {
   double seconds;
@@ -2925,6 +2942,16 @@ struct extent_access_stats_t {
     load_absent -= o.load_absent;
     load_present -= o.load_present;
   }
+
+  void divide_by(unsigned d) {
+    trans_pending /= d;
+    trans_dirty /= d;
+    trans_lru /= d;
+    cache_dirty /= d;
+    cache_lru /= d;
+    load_absent /= d;
+    load_present /= d;
+  }
 };
 struct extent_access_stats_printer_t {
   double seconds;
@@ -2957,6 +2984,11 @@ struct cache_access_stats_t {
     s.minus(o.s);
     cache_absent -= o.cache_absent;
   }
+
+  void divide_by(unsigned d) {
+    s.divide_by(d);
+    cache_absent /= d;
+  }
 };
 struct cache_access_stats_printer_t {
   double seconds;