summaryrefslogtreecommitdiff
path: root/memtable
diff options
context:
space:
mode:
authorSiying Dong <siying.d@fb.com>2019-04-08 13:24:29 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-04-08 13:32:06 -0700
commit0bb555630f5e85a1471843f8dc0dabec297c1c49 (patch)
treecc9de291a64c1383d586751ac16b171a87f6efe3 /memtable
parentde00f28132bd91593f9fd1d565189f7cfe81918b (diff)
Consolidate hash function used for non-persistent data in a new function (#5155)
Summary: Create new function NPHash64() and GetSliceNPHash64(), which are currently implemented using murmurhash. Replace the current direct call of murmurhash() to use the new functions if the hash results are not used in on-disk format. This will make it easier to try out or switch to alternative functions in the uses where data format compatibility doesn't need to be considered. This part shouldn't have any performance impact. Also, the sharded cache hash function is changed to the new format, because it falls into this categoery. It doesn't show visible performance impact in db_bench results. CPU showed by perf is increased from about 0.2% to 0.4% in an extreme benchmark setting (4KB blocks, no-compression, everything cached in block cache). We've known that the current hash function used, our own Hash() has serious hash quality problem. It can generate a lots of conflicts with similar input. In this use case, it means extra lock contention for reads from the same file. This slight CPU regression is worthy to me to counter the potential bad performance with hot keys. And hopefully this will get further improved in the future with a better hash function. cache_test's condition is relaxed a little bit to. The new hash is slightly more skewed in this use case, but I manually checked the data and see the hash results are still in a reasonable range. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5155 Differential Revision: D14834821 Pulled By: siying fbshipit-source-id: ec9a2c0a2f8ae4b54d08b13a5c2e9cc97aa80cb5
Diffstat (limited to 'memtable')
-rw-r--r--memtable/hash_linklist_rep.cc4
-rw-r--r--memtable/stl_wrappers.h1
2 files changed, 2 insertions, 3 deletions
diff --git a/memtable/hash_linklist_rep.cc b/memtable/hash_linklist_rep.cc
index 7aa0063e9..878d23383 100644
--- a/memtable/hash_linklist_rep.cc
+++ b/memtable/hash_linklist_rep.cc
@@ -17,7 +17,7 @@
#include "rocksdb/slice.h"
#include "rocksdb/slice_transform.h"
#include "util/arena.h"
-#include "util/murmurhash.h"
+#include "util/hash.h"
namespace rocksdb {
namespace {
@@ -218,7 +218,7 @@ class HashLinkListRep : public MemTableRep {
}
size_t GetHash(const Slice& slice) const {
- return MurmurHash(slice.data(), static_cast<int>(slice.size()), 0) %
+ return NPHash64(slice.data(), static_cast<int>(slice.size()), 0) %
bucket_size_;
}
diff --git a/memtable/stl_wrappers.h b/memtable/stl_wrappers.h
index 19fa15148..0287f4f8f 100644
--- a/memtable/stl_wrappers.h
+++ b/memtable/stl_wrappers.h
@@ -11,7 +11,6 @@
#include "rocksdb/memtablerep.h"
#include "rocksdb/slice.h"
#include "util/coding.h"
-#include "util/murmurhash.h"
namespace rocksdb {
namespace stl_wrappers {