From e849fa158b16df9af0352c674d272ee43b4123a1 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Wed, 3 Mar 2021 13:17:05 +0100 Subject: [PATCH] Replace dense_hash_map with F14 maps --- CMakeLists.txt | 5 +---- README.md | 3 +-- src/dwarfs/block_manager.cpp | 14 +++++--------- src/dwarfs/python_script.cpp | 7 +++---- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c423f968..e480f4a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,8 +102,6 @@ if(NOT FUSE_FOUND AND NOT FUSE3_FOUND) message(FATAL_ERROR "No FUSE or FUSE3 library found") endif() -find_path(SPARSEHASH_INCLUDE_DIR sparsehash/dense_hash_map - DOC "dense_hash_map header" REQUIRED) find_program(RONN_EXE ronn DOC "ronn man page generator" REQUIRED) if(USE_JEMALLOC) @@ -358,8 +356,7 @@ list( ${CMAKE_CURRENT_SOURCE_DIR}/fbthrift ${CMAKE_CURRENT_SOURCE_DIR}/zstd/lib ${CMAKE_CURRENT_SOURCE_DIR}/xxHash - ${CMAKE_CURRENT_BINARY_DIR} - ${SPARSEHASH_INCLUDE_DIR}) + ${CMAKE_CURRENT_BINARY_DIR}) if(USE_JEMALLOC) list(APPEND INCLUDE_DIRS ${Jemalloc_INCLUDE_DIRS}) diff --git a/README.md b/README.md index a97177fb..3a351420 100644 --- a/README.md +++ b/README.md @@ -158,8 +158,7 @@ A good starting point for apt-based systems is probably: libelf-dev \ libfmt-dev \ libfuse3-dev \ - libgoogle-glog-dev \ - libsparsehash-dev + libgoogle-glog-dev You can pick either `clang` or `g++`, but at least recent `clang` versions will produce substantially faster code: diff --git a/src/dwarfs/block_manager.cpp b/src/dwarfs/block_manager.cpp index 0aa567c4..6fb34973 100644 --- a/src/dwarfs/block_manager.cpp +++ b/src/dwarfs/block_manager.cpp @@ -31,8 +31,7 @@ #include -#include - +#include #include #include @@ -87,19 +86,16 @@ struct bm_stats { folly::Histogram l2_collision_vec_size; }; -template +template class fast_multimap { private: using collision_vector = folly::small_vector; - using blockhash_t = google::dense_hash_map; - using collision_t = std::unordered_map; + using blockhash_t = folly::F14ValueMap; + using collision_t = folly::F14FastMap; public: - fast_multimap() { values_.set_empty_key(EmptyKey); } - void insert(KeyT const& key, ValT const& val) { - if (key == EmptyKey or !values_.insert(std::make_pair(key, val)).second) { + if (!values_.insert(std::make_pair(key, val)).second) { collisions_[key].emplace_back(val); } } diff --git a/src/dwarfs/python_script.cpp b/src/dwarfs/python_script.cpp index c747d644..4686087d 100644 --- a/src/dwarfs/python_script.cpp +++ b/src/dwarfs/python_script.cpp @@ -26,10 +26,10 @@ #include #include -#include - #include +#include + #include "dwarfs/entry.h" #include "dwarfs/error.h" #include "dwarfs/inode.h" @@ -396,8 +396,7 @@ void python_script::impl::order(inode_vector& iv) { td << "ordered files in script code"; } - google::dense_hash_map priority(iv.size()); - priority.set_empty_key(nullptr); + folly::F14FastMap priority(iv.size()); auto td = LOG_TIMED_DEBUG; size_t index = 0;