From: Jaya Prakash Date: Tue, 16 Jun 2026 16:24:41 +0000 (+0000) Subject: os/bluestore: add per-instance new allocator perf counters X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1a0ee9b11dd6f1a54eeff9240519613ce368d596;p=ceph.git os/bluestore: add per-instance new allocator perf counters Fixes: https://tracker.ceph.com/issues/76936 Signed-off-by: Jaya Prakash --- diff --git a/src/os/bluestore/AllocatorBase.cc b/src/os/bluestore/AllocatorBase.cc index 62d78974e27..a7c068dcfeb 100644 --- a/src/os/bluestore/AllocatorBase.cc +++ b/src/os/bluestore/AllocatorBase.cc @@ -207,3 +207,31 @@ void AllocatorBase::FreeStateHistogram::foreach( ++i; } } +void AllocatorPerf::_init_logger(std::string_view name) { + PerfCountersBuilder b(cct, + "bluestore-alloc-" + std::string(name), + l_bluestore_allocator_first, + l_bluestore_allocator_last); + + b.add_time_avg(l_bluestore_allocator_alloc_process_lat, + "alloc_process_lat", + "Allocator processing latency", + "apl", + PerfCountersBuilder::PRIO_USEFUL); + b.add_time_avg(l_bluestore_allocator_lock_wait_lat, + "lock_wait_lat", + "Allocator lock wait latency", + "lwl", + PerfCountersBuilder::PRIO_USEFUL); + + logger = b.create_perf_counters(); + + cct->get_perfcounters_collection()->add(logger); +} +void AllocatorPerf::_shutdown_logger() { + if (logger) { + cct->get_perfcounters_collection()->remove(logger); + delete logger; + logger = nullptr; + } +} diff --git a/src/os/bluestore/AllocatorBase.h b/src/os/bluestore/AllocatorBase.h index eedf766dc80..dc567c3c2c9 100644 --- a/src/os/bluestore/AllocatorBase.h +++ b/src/os/bluestore/AllocatorBase.h @@ -19,6 +19,15 @@ #include "bluestore_types.h" #include "common/ceph_mutex.h" #include "Allocator.h" +#include "common/perf_counters.h" +#include "common/perf_counters_collection.h" + +enum { + l_bluestore_allocator_first = 732300, + l_bluestore_allocator_alloc_process_lat, + l_bluestore_allocator_lock_wait_lat, + l_bluestore_allocator_last +}; class AllocatorBase : public Allocator { protected: @@ -295,4 +304,24 @@ private: SocketHook* asok_hook = nullptr; }; +class AllocatorPerf { +private: + CephContext* cct = nullptr; +protected: + PerfCounters *logger = nullptr; +public: + AllocatorPerf() = delete; + AllocatorPerf(CephContext* cct, std::string_view name) + : cct(cct) + { + _init_logger(name); + } + ~AllocatorPerf() { + _shutdown_logger(); + } +private: + void _init_logger(std::string_view name); + void _shutdown_logger(); +}; + #endif