Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive Radix Tree: high-performance memtable #273

Open
wants to merge 19 commits into
base: 6.4.tikv
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ make_config.mk
*.gcda
*.gcno
*.o
*.o.tmp
*.so
*.so.*
*_test
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ set(SOURCES
memtable/hash_linklist_rep.cc
memtable/hash_skiplist_rep.cc
memtable/skiplistrep.cc
memtable/artrep.cc
memtable/art.cc
memtable/vectorrep.cc
memtable/write_buffer_manager.cc
monitoring/histogram.cc
Expand Down Expand Up @@ -973,6 +975,7 @@ if(WITH_TESTS)
memory/arena_test.cc
memtable/inlineskiplist_test.cc
memtable/skiplist_test.cc
memtable/art_test.cc
memtable/write_buffer_manager_test.cc
monitoring/histogram_test.cc
monitoring/iostats_context_test.cc
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ TESTS = \
crc32c_test \
coding_test \
inlineskiplist_test \
art_test \
encryption_test \
env_basic_test \
env_test \
Expand Down Expand Up @@ -1423,6 +1424,9 @@ data_block_hash_index_test: table/block_based/data_block_hash_index_test.o $(LIB
inlineskiplist_test: memtable/inlineskiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK)

art_test: memtable/art_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK)

skiplist_test: memtable/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
$(AM_LINK)

Expand Down
9 changes: 9 additions & 0 deletions TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ cpp_library(
"memory/concurrent_arena.cc",
"memory/jemalloc_nodump_allocator.cc",
"memtable/alloc_tracker.cc",
"memtable/art.cc",
"memtable/artrep.cc",
"memtable/hash_linklist_rep.cc",
"memtable/hash_skiplist_rep.cc",
"memtable/skiplistrep.cc",
Expand Down Expand Up @@ -1255,6 +1257,13 @@ ROCKS_TESTS = [
[],
[],
],
[
"art_test",
"memtable/art_test.cc",
"serial",
[],
[],
],
[
"slice_transform_test",
"util/slice_transform_test.cc",
Expand Down
3 changes: 0 additions & 3 deletions db/db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1021,18 +1021,15 @@ TEST_F(DBTest, FailMoreDbPaths) {

void CheckColumnFamilyMeta(const ColumnFamilyMetaData& cf_meta) {
uint64_t cf_size = 0;
uint64_t cf_csize = 0;
size_t file_count = 0;
for (auto level_meta : cf_meta.levels) {
uint64_t level_size = 0;
uint64_t level_csize = 0;
file_count += level_meta.files.size();
for (auto file_meta : level_meta.files) {
level_size += file_meta.size;
}
ASSERT_EQ(level_meta.size, level_size);
cf_size += level_size;
cf_csize += level_csize;
}
ASSERT_EQ(cf_meta.file_count, file_count);
ASSERT_EQ(cf_meta.size, cf_size);
Expand Down
6 changes: 2 additions & 4 deletions db/perf_context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,8 @@ TEST_F(PerfContextTest, BitMapControl) {
auto db = OpenDb();
WriteOptions write_options;
SetPerfLevel(PerfLevel::kDisable);
SetPerfFlags(NewPerfFlags({
PerfFlag::user_key_comparison_count,
PerfFlag::write_wal_time
}));
SetPerfFlags(NewPerfFlags(
{PerfFlag::user_key_comparison_count, PerfFlag::write_wal_time}));

for (int i = 0; i < FLAGS_total_keys; ++i) {
std::string i_str = ToString(i);
Expand Down
18 changes: 18 additions & 0 deletions include/rocksdb/memtablerep.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,24 @@ class DoublySkipListFactory : public MemTableRepFactory {
const size_t lookahead_;
};

// This uses an adaptive radix tree to store keys, which is similar to trie,
// but optimize for memory use.
class AdaptiveRadixTreeFactory : public MemTableRepFactory {
public:
explicit AdaptiveRadixTreeFactory() {}
virtual ~AdaptiveRadixTreeFactory() {}

using MemTableRepFactory::CreateMemTableRep;
MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator&, Allocator*,
const SliceTransform*,
Logger* logger) override;
const char* Name() const override { return "AdaptiveRadixTreeFactory"; }

bool IsInsertConcurrentlySupported() const override { return false; }

bool CanHandleDuplicatedKey() const override { return false; }
};

#ifndef ROCKSDB_LITE
// This creates MemTableReps that are backed by an std::vector. On iteration,
// the vector is sorted. This is useful for workloads where iteration is very
Expand Down
Loading