From c3e23dd53d62ae4aeb565fdefbd09b75e2d7bc22 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Sat, 7 May 2022 16:00:22 +0800 Subject: [PATCH] crimson/os/seastore/segment_cleaner: refine metrics Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/segment_cleaner.cc | 35 +++++++++++++++------ src/crimson/os/seastore/segment_cleaner.h | 36 ++++++++++++++++------ 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/crimson/os/seastore/segment_cleaner.cc b/src/crimson/os/seastore/segment_cleaner.cc index cf087c69a0534..ae3535f2d633d 100644 --- a/src/crimson/os/seastore/segment_cleaner.cc +++ b/src/crimson/os/seastore/segment_cleaner.cc @@ -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 { diff --git a/src/crimson/os/seastore/segment_cleaner.h b/src/crimson/os/seastore/segment_cleaner.h index 09b8aebfd2b9a..6979d9d38d2b3 100644 --- a/src/crimson/os/seastore/segment_cleaner.h +++ b/src/crimson/os/seastore/segment_cleaner.h @@ -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; + } }); } -- 2.39.5