uint64_t max_mem,
std::string_view name) :
AllocatorBase(name, device_size, block_size),
+ AllocatorPerf(cct, name),
cct(cct),
range_size_alloc_threshold(
cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),
max_alloc_size >= cap) {
max_alloc_size = p2align(uint64_t(cap), (uint64_t)block_size);
}
+ auto lock_wait_start = mono_clock::now();
+
std::lock_guard l(lock);
- return _allocate(want, unit, max_alloc_size, hint, extents);
+
+ auto lock_acquired = mono_clock::now();
+
+ auto ret = _allocate(want, unit, max_alloc_size, hint, extents);
+
+ 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 ret;
}
void AvlAllocator::release(const release_set_t& release_set) {
boost::intrusive::avl_set_member_hook<> size_hook;
};
-class AvlAllocator : public AllocatorBase {
+class AvlAllocator : public AllocatorBase, public AllocatorPerf {
struct dispose_rs {
void operator()(range_seg_t* p)
{
bool with_cache,
std::string_view name) :
AllocatorBase(name, device_size, block_size),
+ AllocatorPerf(_cct, name),
myTraits(RANGE_SIZE_BUCKET_COUNT),
cct(_cct),
range_count_cap(max_mem / sizeof(range_seg_t))
extents->emplace_back(cached_chunk_offs, want);
return want;
}
+ auto lock_wait_start = mono_clock::now();
+
std::lock_guard l(lock);
- return _allocate(want, unit, max_alloc_size, hint, extents);
+
+ auto lock_acquired = mono_clock::now();
+
+ auto ret = _allocate(want, unit, max_alloc_size, hint, extents);
+
+ 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 ret;
}
void Btree2Allocator::release(const release_set_t& release_set)
*
*
*/
-class Btree2Allocator : public AllocatorBase {
+class Btree2Allocator : public AllocatorBase, public AllocatorPerf {
enum {
RANGE_SIZE_BUCKET_COUNT = 14,
};
uint64_t max_mem,
std::string_view name) :
AllocatorBase(name, device_size, block_size),
+ AllocatorPerf(cct, name),
range_size_alloc_threshold(
cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),
range_size_alloc_free_pct(
max_alloc_size >= cap) {
max_alloc_size = p2align(uint64_t(cap), (uint64_t)block_size);
}
+ auto lock_wait_start = mono_clock::now();
+
std::lock_guard l(lock);
- return _allocate(want, unit, max_alloc_size, hint, extents);
+
+ auto lock_acquired = mono_clock::now();
+
+ auto ret = _allocate(want, unit, max_alloc_size, hint, extents);
+
+ 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 ret;
}
void BtreeAllocator::release(const interval_set<uint64_t>& release_set) {
#include "os/bluestore/bluestore_types.h"
#include "include/mempool.h"
-class BtreeAllocator : public AllocatorBase {
+class BtreeAllocator : public AllocatorBase, public AllocatorPerf {
struct range_seg_t {
uint64_t start; ///< starting offset of this segment
uint64_t end; ///< ending offset (non-inclusive)
max_alloc_size = p2align(uint64_t(cap), (uint64_t)T::get_block_size());
}
+ auto lock_wait_start = mono_clock::now();
+
std::lock_guard l(T::get_lock());
+ auto lock_acquired = mono_clock::now();
+
// try bitmap first to avoid unneeded contiguous extents split if
// desired amount is less than shortes range in AVL or Btree2
bool primary_first = !(bmap_alloc &&
ceph_assert(orig_size == extents->size());
}
}
+ this->logger->tinc_with_max(
+ l_bluestore_allocator_alloc_process_lat,
+ mono_clock::now() - lock_acquired);
+ this->logger->tinc_with_max(
+ l_bluestore_allocator_lock_wait_lat,
+ lock_acquired - lock_wait_start);
return res ? res : -ENOSPC;
}
int64_t _block_size,
std::string_view name)
: AllocatorBase(name, capacity, _block_size),
+ AllocatorPerf(cct, name),
cct(cct), num_free(0),
free(10)
{
uint64_t want_size, uint64_t alloc_unit, int64_t hint,
uint64_t *offset, uint32_t *length)
{
+ auto lock_wait_start = mono_clock::now();
+
std::lock_guard l(lock);
+
+ auto lock_acquired = mono_clock::now();
+
ldout(cct, 10) << __func__ << " want_size 0x" << std::hex << want_size
<< " alloc_unit 0x" << alloc_unit
<< " hint 0x" << hint << std::dec
num_free -= *length;
ceph_assert(num_free >= 0);
last_alloc = *offset + *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 0;
}
#include "include/mempool.h"
#include "common/ceph_mutex.h"
-class StupidAllocator : public AllocatorBase {
+class StupidAllocator : public AllocatorBase, public AllocatorPerf {
CephContext* cct;
ceph::mutex lock = ceph::make_mutex("StupidAllocator::lock");