From: Jaya Prakash Date: Wed, 17 Jun 2026 12:47:38 +0000 (+0000) Subject: os/bluestore: measure Bitmap allocator lock wait and processing latency X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1004a24ecaf344545522c577206215a7b8857716;p=ceph.git os/bluestore: measure Bitmap allocator lock wait and processing latency Fixes: https://tracker.ceph.com/issues/76936 Signed-off-by: Jaya Prakash --- diff --git a/src/os/bluestore/BitmapAllocator.cc b/src/os/bluestore/BitmapAllocator.cc index 3ab43bea344..ec53216cf98 100644 --- a/src/os/bluestore/BitmapAllocator.cc +++ b/src/os/bluestore/BitmapAllocator.cc @@ -14,6 +14,7 @@ BitmapAllocator::BitmapAllocator(CephContext* _cct, int64_t alloc_unit, std::string_view name) : AllocatorBase(name, capacity, alloc_unit), + AllocatorLevel02(_cct, name), cct(_cct) { ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/" diff --git a/src/os/bluestore/fastbmap_allocator_impl.h b/src/os/bluestore/fastbmap_allocator_impl.h index fbf3fda0b32..2ae809ec431 100644 --- a/src/os/bluestore/fastbmap_allocator_impl.h +++ b/src/os/bluestore/fastbmap_allocator_impl.h @@ -15,6 +15,7 @@ #include #include #include +#include typedef uint64_t slot_t; @@ -36,6 +37,7 @@ typedef std::vector 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 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 diff --git a/src/test/objectstore/fastbmap_allocator_test.cc b/src/test/objectstore/fastbmap_allocator_test.cc index 83babab567f..7cd8d6adb81 100644 --- a/src/test/objectstore/fastbmap_allocator_test.cc +++ b/src/test/objectstore/fastbmap_allocator_test.cc @@ -27,6 +27,8 @@ public: class TestAllocatorLevel02 : public AllocatorLevel02 { public: + TestAllocatorLevel02() + : AllocatorLevel02(g_ceph_context, "bitmap-test") {} void init(uint64_t capacity, uint64_t alloc_unit) { _init(capacity, alloc_unit);