Use emhash hashmap (2x faster)

This commit is contained in:
Vitaliy Filippov
2025-12-02 01:52:12 +03:00
parent 8189c3a4ef
commit af710d3c65
4 changed files with 10 additions and 5 deletions
+3
View File
@@ -4,3 +4,6 @@
[submodule "json11"]
path = json11
url = ../json11.git
[submodule "emhash"]
path = emhash
url = ../emhash.git
Submodule
+1
Submodule emhash added at b7ff3147a5
+2 -2
View File
@@ -541,7 +541,7 @@ uint64_t blockstore_heap_t::load_blocks(uint64_t disk_offset, uint64_t size, uin
next_lsn = wr->lsn;
}
}
// btree_map<ui64, ui32> anyway stores std::pair<ui64, ui32>'s of 16 bytes size
// maps anyway store std::pair<ui64, ui32>'s of 16 bytes size
// so we can store block_offset in it too
block_index[get_pg_id(obj->inode, obj->stripe)][obj->inode][obj->stripe] = (uint8_t*)obj - buf + disk_offset;
entries_loaded += wr_i;
@@ -818,7 +818,7 @@ void blockstore_heap_t::reshard(pool_id_t pool, uint32_t pg_count, uint32_t pg_s
return;
}
uint64_t pool_id = (uint64_t)pool;
std::unordered_map<uint64_t, std::unordered_map<inode_t, std::unordered_map<uint64_t, uint64_t>>> new_shards;
emhash7::HashMap<uint64_t, emhash7::HashMap<inode_t, emhash5::HashMap<uint64_t, uint64_t>>> new_shards;
auto sh_it = block_index.begin();
while (sh_it != block_index.end())
{
+4 -3
View File
@@ -11,7 +11,8 @@
#include <vector>
#include "../client/object_id.h"
//#include "../../cpp-btree/btree_map.h"
#include "../../emhash/hash_table5.hpp"
#include "../../emhash/hash_table7.hpp"
#include "blockstore_disk.h"
#include "multilist.h"
@@ -137,9 +138,9 @@ class blockstore_heap_t
uint32_t target_block_free_space = 800;
uint64_t next_lsn = 0;
std::unordered_map<pool_id_t, pool_shard_settings_t> pool_shard_settings;
emhash7::HashMap<pool_id_t, pool_shard_settings_t> pool_shard_settings;
// PG => inode => stripe => block number
std::unordered_map<uint64_t, std::unordered_map<inode_t, std::unordered_map<uint64_t, uint64_t>>> block_index;
emhash7::HashMap<uint64_t, emhash7::HashMap<inode_t, emhash5::HashMap<uint64_t, uint64_t>>> block_index;
std::vector<heap_block_info_t> block_info;
allocator_t *data_alloc = NULL;
multilist_index_t *meta_alloc = NULL;