Skip to content

Commit 56744f2

Browse files
committed
introduce boost::unordered_flat_map
1 parent b0d8948 commit 56744f2

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/replica/mutation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "mutation.h"
2828

2929
#include <boost/intrusive/detail/slist_iterator.hpp>
30+
#include <boost/unordered/detail/fca.hpp>
31+
#include <boost/unordered/detail/implementation.hpp>
3032
#include <cinttypes>
3133
#include <cstring>
3234
#include <string>

src/replica/mutation.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include <boost/intrusive/slist.hpp>
3030
#include <boost/intrusive/slist_hook.hpp>
31-
#include <boost/unordered_map.hpp>
31+
#include <boost/unordered/unordered_flat_map.hpp>
3232
#include <algorithm>
3333
#include <atomic>
3434
#include <cstddef>
@@ -397,8 +397,15 @@ class mutation_queue
397397

398398
// rather than real hash key, where deserialize will consume cpu.
399399
// partition_hash => count
400+
//
401+
// TODO(wangdan): consider comparing performance between boost::unordered_flat_map
402+
// and absl::flat_hash_map, both of which are based on open addressing.
403+
// Introducing absl::flat_hash_map is very easy, just by:
400404
// using row_lock_map = absl::flat_hash_map<uint64_t, size_t>;
401-
using row_lock_map = boost::unordered_map<uint64_t, size_t>;
405+
// I've tried to introduce absl::flat_hash_map; however, it could not pass the ASAN
406+
// tests due to segmentation fault caused by dereferencing a null pointer inside
407+
// "absl/container/internal/raw_hash_set.h". I'll try it again later.
408+
using row_lock_map = boost::unordered_flat_map<uint64_t, size_t>;
402409
row_lock_map _row_locks;
403410
};
404411

0 commit comments

Comments
 (0)