From 3d9ce6e1d8638999fee19295e08d5c23c24d8ae5 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Mon, 2 Sep 2024 11:38:40 +0800 Subject: [PATCH] crimson/os/seastore: cleanups to SeaStore::report_stats() Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/seastore.cc | 27 ++++---------------- src/crimson/os/seastore/seastore_types.h | 32 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index e41de39fa729..157743323735 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -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}); diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index 62bb3e386359..df5c184e7ab0 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -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; -- 2.47.3