From 0a5ad093705484369952d478e9b21e915860273a Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Thu, 22 Jul 2021 19:39:21 +0300 Subject: [PATCH] os/bluestore: implement allocation perf histogram. This allows to monitor how fragmented resulting allocations are depending on the requested block size. Could be coupled with https://github.com/ceph/ceph/pull/41600/ for easy live monitoring for either an individual OSD or full set of them. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 31 ++++++++++++++++++++++++++++--- src/os/bluestore/BlueStore.h | 3 ++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5368993ff0d..cd3d33329ff 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5030,6 +5030,27 @@ void BlueStore::_init_logger() b.add_time_avg(l_bluestore_remove_lat, "remove_lat", "Average removal latency"); + // Resulting size axis configuration for op histograms, values are in bytes + PerfHistogramCommon::axis_config_d alloc_hist_x_axis_config{ + "Given size (bytes)", + PerfHistogramCommon::SCALE_LOG2, ///< Request size in logarithmic scale + 0, ///< Start at 0 + 4096, ///< Quantization unit + 13, ///< Enough to cover 4+M requests + }; + // Req size axis configuration for op histograms, values are in bytes + PerfHistogramCommon::axis_config_d alloc_hist_y_axis_config{ + "Request size (bytes)", + PerfHistogramCommon::SCALE_LOG2, ///< Request size in logarithmic scale + 0, ///< Start at 0 + 4096, ///< Quantization unit + 13, ///< Enough to cover 4+M requests + }; + b.add_u64_counter_histogram( + l_bluestore_allocate_hist, "allocate_histogram", + alloc_hist_x_axis_config, alloc_hist_y_axis_config, + "Histogram of requested block allocations vs. given ones"); + logger = b.create_perf_counters(); cct->get_perfcounters_collection()->add(logger); } @@ -14138,7 +14159,7 @@ int BlueStore::_do_alloc_write( } return -ENOSPC; } - _collect_allocation_stats(need, min_alloc_size, prealloc.size()); + _collect_allocation_stats(need, min_alloc_size, prealloc); dout(20) << __func__ << " prealloc " << prealloc << dendl; auto prealloc_pos = prealloc.begin(); @@ -16123,11 +16144,15 @@ void BlueStore::_log_alerts(osd_alert_list_t& alerts) } void BlueStore::_collect_allocation_stats(uint64_t need, uint32_t alloc_size, - size_t extents) + const PExtentVector& extents) { alloc_stats_count++; - alloc_stats_fragments += extents; + alloc_stats_fragments += extents.size(); alloc_stats_size += need; + + for (auto& e : extents) { + logger->hinc(l_bluestore_allocate_hist, e.length, need); + } } void BlueStore::_record_allocation_stats() diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index c9f31672192..a73b3b85335 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -144,6 +144,7 @@ enum { l_bluestore_omap_get_values_lat, l_bluestore_clist_lat, l_bluestore_remove_lat, + l_bluestore_allocate_hist, l_bluestore_last }; @@ -3357,7 +3358,7 @@ private: unsigned bits); void _collect_allocation_stats(uint64_t need, uint32_t alloc_size, - size_t extents); + const PExtentVector&); void _record_allocation_stats(); private: uint64_t probe_count = 0; -- 2.39.5