os/bluestore: add per-instance new allocator perf counters

Fixes: https://tracker.ceph.com/issues/76936

Signed-off-by: Jaya Prakash <jayaprakash@ibm.com>
This commit is contained in:
Jaya Prakash 2026-06-16 16:24:41 +00:00
parent 14deb05b8e
commit 1a0ee9b11d
2 changed files with 57 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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