Replace dense_hash_map with F14 maps

This commit is contained in:
Marcus Holland-Moritz 2021-03-03 13:17:05 +01:00
parent 41c76963b1
commit e849fa158b
4 changed files with 10 additions and 19 deletions

View File

@ -102,8 +102,6 @@ if(NOT FUSE_FOUND AND NOT FUSE3_FOUND)
message(FATAL_ERROR "No FUSE or FUSE3 library found") message(FATAL_ERROR "No FUSE or FUSE3 library found")
endif() 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) find_program(RONN_EXE ronn DOC "ronn man page generator" REQUIRED)
if(USE_JEMALLOC) if(USE_JEMALLOC)
@ -358,8 +356,7 @@ list(
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift ${CMAKE_CURRENT_SOURCE_DIR}/fbthrift
${CMAKE_CURRENT_SOURCE_DIR}/zstd/lib ${CMAKE_CURRENT_SOURCE_DIR}/zstd/lib
${CMAKE_CURRENT_SOURCE_DIR}/xxHash ${CMAKE_CURRENT_SOURCE_DIR}/xxHash
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
${SPARSEHASH_INCLUDE_DIR})
if(USE_JEMALLOC) if(USE_JEMALLOC)
list(APPEND INCLUDE_DIRS ${Jemalloc_INCLUDE_DIRS}) list(APPEND INCLUDE_DIRS ${Jemalloc_INCLUDE_DIRS})

View File

@ -158,8 +158,7 @@ A good starting point for apt-based systems is probably:
libelf-dev \ libelf-dev \
libfmt-dev \ libfmt-dev \
libfuse3-dev \ libfuse3-dev \
libgoogle-glog-dev \ libgoogle-glog-dev
libsparsehash-dev
You can pick either `clang` or `g++`, but at least recent `clang` You can pick either `clang` or `g++`, but at least recent `clang`
versions will produce substantially faster code: versions will produce substantially faster code:

View File

@ -31,8 +31,7 @@
#include <fmt/format.h> #include <fmt/format.h>
#include <sparsehash/dense_hash_map> #include <folly/container/F14Map.h>
#include <folly/small_vector.h> #include <folly/small_vector.h>
#include <folly/stats/Histogram.h> #include <folly/stats/Histogram.h>
@ -87,19 +86,16 @@ struct bm_stats {
folly::Histogram<size_t> l2_collision_vec_size; folly::Histogram<size_t> l2_collision_vec_size;
}; };
template <typename KeyT, typename ValT, KeyT EmptyKey = KeyT{}, template <typename KeyT, typename ValT, size_t MaxCollInline = 2>
size_t MaxCollInline = 2>
class fast_multimap { class fast_multimap {
private: private:
using collision_vector = folly::small_vector<ValT, MaxCollInline>; using collision_vector = folly::small_vector<ValT, MaxCollInline>;
using blockhash_t = google::dense_hash_map<KeyT, ValT>; using blockhash_t = folly::F14ValueMap<KeyT, ValT>;
using collision_t = std::unordered_map<KeyT, collision_vector>; using collision_t = folly::F14FastMap<KeyT, collision_vector>;
public: public:
fast_multimap() { values_.set_empty_key(EmptyKey); }
void insert(KeyT const& key, ValT const& val) { 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); collisions_[key].emplace_back(val);
} }
} }

View File

@ -26,10 +26,10 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include <sparsehash/dense_hash_map>
#include <fmt/format.h> #include <fmt/format.h>
#include <folly/container/F14Map.h>
#include "dwarfs/entry.h" #include "dwarfs/entry.h"
#include "dwarfs/error.h" #include "dwarfs/error.h"
#include "dwarfs/inode.h" #include "dwarfs/inode.h"
@ -396,8 +396,7 @@ void python_script::impl::order(inode_vector& iv) {
td << "ordered files in script code"; td << "ordered files in script code";
} }
google::dense_hash_map<inode const*, size_t> priority(iv.size()); folly::F14FastMap<inode const*, size_t> priority(iv.size());
priority.set_empty_key(nullptr);
auto td = LOG_TIMED_DEBUG; auto td = LOG_TIMED_DEBUG;
size_t index = 0; size_t index = 0;