.set_default(4)
.set_description(""),
+ Option("bluestore_hybrid_alloc_mem_cap", Option::TYPE_UINT, Option::LEVEL_DEV)
+ .set_default(64_M)
+ .set_description("Maximum RAM hybrid allocator should use before enabling bitmap supplement"),
+
// -----------------------------------------
// kstore
} else if (type == "avl") {
return new AvlAllocator(cct, size, block_size, name);
} else if (type == "hybrid") {
- return new HybridAllocator(cct, size, block_size, 1024 /*FIXME*/, name);
+ return new HybridAllocator(cct, size, block_size,
+ cct->_conf.get_val<uint64_t>("bluestore_hybrid_alloc_mem_cap"),
+ name);
}
if (alloc == nullptr) {
lderr(cct) << "Allocator::" << __func__ << " unknown alloc type "
AvlAllocator::AvlAllocator(CephContext* cct,
int64_t device_size,
int64_t block_size,
- uint64_t max_entries,
+ uint64_t max_mem,
const std::string& name) :
Allocator(name),
num_total(device_size),
cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),
range_size_alloc_free_pct(
cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_free_pct")),
- range_count_cap(max_entries),
+ range_count_cap(max_mem / sizeof(range_seg_t)),
cct(cct)
{}
* (when entry count >= max_entries)
*/
AvlAllocator(CephContext* cct, int64_t device_size, int64_t block_size,
- uint64_t max_entries,
+ uint64_t max_mem,
const std::string& name);
public:
BitmapAllocator* bmap_alloc = nullptr;
public:
HybridAllocator(CephContext* cct, int64_t device_size, int64_t _block_size,
- uint64_t max_entries,
+ uint64_t max_mem,
const std::string& name) :
- AvlAllocator(cct, device_size, _block_size, max_entries, name) {
+ AvlAllocator(cct, device_size, _block_size, max_mem, name) {
}
int64_t allocate(
uint64_t want,
{
uint64_t block_size = 0x1000;
uint64_t capacity = 0x10000 * _1m; // = 64GB
- TestHybridAllocator ha(g_ceph_context, capacity, block_size, 4, "test_hybrid_allocator");
+ TestHybridAllocator ha(g_ceph_context, capacity, block_size,
+ 4 * sizeof(range_seg_t), "test_hybrid_allocator");
ASSERT_EQ(0, ha.get_free());
ASSERT_EQ(0, ha.get_avl_free());