Remove std::set meta_nearfull

This commit is contained in:
Vitaliy Filippov
2025-12-02 01:52:12 +03:00
parent e1bb670491
commit 7287b7fc25
4 changed files with 15 additions and 13 deletions
+9 -12
View File
@@ -834,13 +834,18 @@ int blockstore_heap_t::allocate_entry(uint32_t entry_size, uint32_t *block_num,
last_allocated_block = UINT32_MAX;
}
}
if (last_allocated_block == UINT32_MAX && meta_nearfull.size() > 0)
if (last_allocated_block == UINT32_MAX)
{
// Then into nearfull blocks
auto most_free = *std::prev(meta_nearfull.end());
if ((most_free >> 32) >= entry_size)
for (uint32_t b = meta_alloc->find(META_ALLOC_LEVELS-1); b != UINT32_MAX; b = meta_alloc->next(b))
{
last_allocated_block = (uint32_t)most_free;
auto & inf = block_info.at(b);
auto free_space = dsk->meta_block_size - inf.used_space;
if (free_space >= entry_size)
{
last_allocated_block = b;
break;
}
}
}
if (last_allocated_block == UINT32_MAX)
@@ -1317,14 +1322,6 @@ void blockstore_heap_t::modify_alloc(uint32_t block_num, std::function<void(heap
{
meta_nearfull_blocks += (new_pos >= META_ALLOC_LEVELS-1 ? 1 : -1);
}
if (old_pos == META_ALLOC_LEVELS-1 || new_pos == META_ALLOC_LEVELS-1)
{
// block is nearfull -> free space between minimum and maximum entry size
if (old_pos == META_ALLOC_LEVELS-1)
meta_nearfull.erase(block_num | (((uint64_t)(dsk->meta_block_size-old_used)) << 32));
if (new_pos == META_ALLOC_LEVELS-1)
meta_nearfull.insert(block_num | (((uint64_t)(dsk->meta_block_size-new_used)) << 32));
}
}
void blockstore_heap_t::start_block_write(uint32_t block_num)
-1
View File
@@ -139,7 +139,6 @@ class blockstore_heap_t
std::vector<heap_block_info_t> block_info;
allocator_t *data_alloc = NULL;
multilist_index_t *meta_alloc = NULL;
std::set<uint64_t> meta_nearfull;
uint32_t meta_nearfull_blocks = 0;
uint64_t meta_used_space = 0;
multilist_alloc_t *buffer_alloc = NULL;
+5
View File
@@ -300,6 +300,11 @@ uint32_t multilist_index_t::find(uint32_t wanted_used)
return heads[wanted_used];
}
uint32_t multilist_index_t::next(uint32_t pos)
{
return nexts[pos];
}
void multilist_index_t::change(uint32_t pos, uint32_t old_used, uint32_t new_used)
{
if (new_used == old_used)
+1
View File
@@ -32,6 +32,7 @@ struct multilist_index_t
// used should be always < max_used
multilist_index_t(uint32_t count, uint32_t max_used, uint32_t init_used);
uint32_t find(uint32_t wanted_used);
uint32_t next(uint32_t pos);
void change(uint32_t pos, uint32_t old_used, uint32_t new_used);
void print();
};