]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: measure Bitmap allocator lock wait and processing latency
authorJaya Prakash <jayaprakash@ibm.com>
Wed, 17 Jun 2026 12:47:38 +0000 (12:47 +0000)
committerJaya Prakash <jayaprakash@ibm.com>
Thu, 25 Jun 2026 10:42:33 +0000 (10:42 +0000)
Fixes: https://tracker.ceph.com/issues/76936
Signed-off-by: Jaya Prakash <jayaprakash@ibm.com>
src/os/bluestore/BitmapAllocator.cc
src/os/bluestore/fastbmap_allocator_impl.h
src/test/objectstore/fastbmap_allocator_test.cc

index 3ab43bea344cc03ae2c2aef09f759e2bc85c7131..ec53216cf9830af1aa7c90b856a6163ecb2a6762 100644 (file)
@@ -14,6 +14,7 @@ BitmapAllocator::BitmapAllocator(CephContext* _cct,
                                         int64_t alloc_unit,
                                         std::string_view name) :
     AllocatorBase(name, capacity, alloc_unit),
+    AllocatorLevel02<AllocatorLevel01Loose>(_cct, name),
     cct(_cct)
 {
   ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/"
index fbf3fda0b327ca80a91c24ca70e2ab9abf76a497..2ae809ec4310a9028edb161df445e9f60a405a50 100644 (file)
@@ -15,6 +15,7 @@
 #include <vector>
 #include <algorithm>
 #include <mutex>
+#include <string_view>
 
 typedef uint64_t slot_t;
 
@@ -36,6 +37,7 @@ typedef std::vector<slot_t> slot_vector_t;
 #include "include/ceph_assert.h"
 #include "common/likely.h"
 #include "os/bluestore/bluestore_types.h"
+#include "AllocatorBase.h"
 #include "include/mempool.h"
 #include "common/ceph_mutex.h"
 
@@ -524,9 +526,13 @@ public:
 };
 
 template <class L1>
-class AllocatorLevel02 : public AllocatorLevel
+class AllocatorLevel02 : public AllocatorLevel, public AllocatorPerf
 {
 public:
+  AllocatorLevel02(CephContext* cct, std::string_view name)
+    : AllocatorPerf(cct, name)
+  {}
+
   uint64_t debug_get_free(uint64_t pos0 = 0, uint64_t pos1 = 0)
   {
     std::lock_guard l(lock);
@@ -720,9 +726,19 @@ protected:
 
     uint64_t l1_w = slots_per_slotset * l1._children_per_slot();
 
+    auto lock_wait_start = mono_clock::now();
+
     std::lock_guard l(lock);
 
+    auto lock_acquired = mono_clock::now();
+
     if (available < min_length) {
+      logger->tinc_with_max(
+        l_bluestore_allocator_alloc_process_lat,
+        mono_clock::now() - lock_acquired);
+      logger->tinc_with_max(
+        l_bluestore_allocator_lock_wait_lat,
+        lock_acquired - lock_wait_start);
       return;
     }
     if (hint != -1) {
@@ -783,6 +799,13 @@ protected:
     auto allocated_here = *allocated - prev_allocated;
     ceph_assert(available >= allocated_here);
     available -= allocated_here;
+
+    logger->tinc_with_max(
+      l_bluestore_allocator_alloc_process_lat,
+      mono_clock::now() - lock_acquired);
+    logger->tinc_with_max(
+      l_bluestore_allocator_lock_wait_lat,
+      lock_acquired - lock_wait_start);
   }
 
 #ifndef NON_CEPH_BUILD
index 83babab567f2cc6bf8cfc35a125322066ca2db55..7cd8d6adb81b23740d9d7b8bdebd4cddf5701b57 100644 (file)
@@ -27,6 +27,8 @@ public:
 class TestAllocatorLevel02 : public AllocatorLevel02<AllocatorLevel01Loose>
 {
 public:
+  TestAllocatorLevel02()
+    : AllocatorLevel02(g_ceph_context, "bitmap-test") {}
   void init(uint64_t capacity, uint64_t alloc_unit)
   {
     _init(capacity, alloc_unit);