From 342502e87f227ef39bf2f67306e0fc2e4b1acaae Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Thu, 2 Mar 2017 03:24:00 +0100 Subject: [PATCH] os/bluestore: leverage the type knowledge in BitMapAreaLeaf. We're sure the only element type BitMapAreaLeaf aggregates is BitMapZone. There is no business to go through vptrs and thus prohibit compiler to inline in a method that is crucial for overall performance of the BitMap allocator. Signed-off-by: Radoslaw Zarzynski --- src/os/bluestore/BitAllocator.cc | 18 +++++++++--------- src/os/bluestore/BitAllocator.h | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/os/bluestore/BitAllocator.cc b/src/os/bluestore/BitAllocator.cc index 238f5f36dfc9..b5dea053cc79 100644 --- a/src/os/bluestore/BitAllocator.cc +++ b/src/os/bluestore/BitAllocator.cc @@ -1095,7 +1095,9 @@ BitMapAreaLeaf::~BitMapAreaLeaf() unlock(); } -bool BitMapAreaLeaf::child_check_n_lock(BitMapArea *child, int64_t required, bool lock) +bool BitMapAreaLeaf::child_check_n_lock(BitMapZone* const child, + const int64_t required, + const bool lock) { /* The exhausted check can be performed without acquiring the lock. This * is because 1) BitMapZone::is_exhausted() actually operates atomically @@ -1120,22 +1122,20 @@ bool BitMapAreaLeaf::child_check_n_lock(BitMapArea *child, int64_t required, boo return true; } -void BitMapAreaLeaf::child_unlock(BitMapArea *child) -{ - child->unlock(); -} - int64_t BitMapAreaLeaf::alloc_blocks_dis_int(int64_t num_blocks, int64_t min_alloc, int64_t hint, int64_t area_blk_off, ExtentList *block_list) { - BitMapArea *child = NULL; + BitMapZone* child = nullptr; int64_t allocated = 0; int64_t blk_off = 0; BmapEntityListIter iter = BmapEntityListIter( m_child_list, hint / m_child_size_blocks, false); - while ((child = (BitMapArea *) iter.next())) { + /* We're sure the only element type we aggregate is BitMapZone, + * so there is no business to go through vptr and thus prohibit + * compiler to inline the stuff. Consult BitMapAreaLeaf::init. */ + while ((child = static_cast(iter.next()))) { if (!child_check_n_lock(child, 1, false)) { hint = 0; continue; @@ -1144,7 +1144,7 @@ int64_t BitMapAreaLeaf::alloc_blocks_dis_int(int64_t num_blocks, int64_t min_all blk_off = child->get_index() * m_child_size_blocks + area_blk_off; allocated += child->alloc_blocks_dis(num_blocks - allocated, min_alloc, hint % m_child_size_blocks, blk_off, block_list); - child_unlock(child); + child->unlock(); if (allocated == num_blocks) { break; } diff --git a/src/os/bluestore/BitAllocator.h b/src/os/bluestore/BitAllocator.h index e12b256e2c87..2b24a324fcee 100644 --- a/src/os/bluestore/BitAllocator.h +++ b/src/os/bluestore/BitAllocator.h @@ -450,8 +450,7 @@ public: return false; } - bool child_check_n_lock(BitMapArea *child, int64_t required, bool lock); - void child_unlock(BitMapArea *child); + bool child_check_n_lock(BitMapZone* child, int64_t required, bool lock); int64_t alloc_blocks_int(int64_t num_blocks, int64_t hint, int64_t *start_block); int64_t alloc_blocks_dis_int(int64_t num_blocks, int64_t min_alloc, int64_t hint, -- 2.47.3