Skip to content

Commit 424a524

Browse files
committed
[Performance Branch] A Hashed Linked List Based Mem Table
Summary: Implement a mem table, in which keys are hashed based on prefixes. In each bucket, entries are organized in a sorted linked list. It has the same thread safety guarantee as skip list. The motivation is to optimize memory usage for the case that prefix hashing is primary way of seeking to the entry. Compared to hash skip list implementation, this implementation is more memory efficient, but inside each bucket, search is always linear. The target scenario is that there are only very limited number of records in each hash bucket. Test Plan: Add a test case in db_test Reviewers: haobo, kailiu, dhruba Reviewed By: haobo CC: igor, nkg-, leveldb Differential Revision: https://reviews.facebook.net/D14979
1 parent 17a2226 commit 424a524

File tree

5 files changed

+716
-175
lines changed

5 files changed

+716
-175
lines changed

db/db_test.cc

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "util/mutexlock.h"
3030
#include "util/testharness.h"
3131
#include "util/testutil.h"
32+
#include "util/hash_linklist_rep.h"
3233
#include "utilities/merge_operators.h"
3334

3435
namespace rocksdb {
@@ -250,6 +251,7 @@ class DBTest {
250251
kPlainTableFirstBytePrefix,
251252
kPlainTableAllBytesPrefix,
252253
kVectorRep,
254+
kHashLinkList,
253255
kMergePut,
254256
kFilter,
255257
kUncompressed,
@@ -403,6 +405,10 @@ class DBTest {
403405
case kVectorRep:
404406
options.memtable_factory.reset(new VectorRepFactory(100));
405407
break;
408+
case kHashLinkList:
409+
options.memtable_factory.reset(
410+
NewHashLinkListRepFactory(NewFixedPrefixTransform(1), 4));
411+
break;
406412
case kUniversalCompaction:
407413
options.compaction_style = kCompactionStyleUniversal;
408414
break;
@@ -4521,6 +4527,7 @@ TEST(DBTest, Randomized) {
45214527
int p = rnd.Uniform(100);
45224528
int minimum = 0;
45234529
if (option_config_ == kHashSkipList ||
4530+
option_config_ == kHashLinkList ||
45244531
option_config_ == kPlainTableFirstBytePrefix) {
45254532
minimum = 1;
45264533
}

0 commit comments

Comments
 (0)