mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-03 17:56:12 -04:00
refactor(block_cache): phmap is as least as fast as F14 (and smaller)
This commit is contained in:
parent
9cdfaffee6
commit
43e42994cb
@ -44,10 +44,11 @@
|
|||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <folly/container/EvictingCacheMap.h>
|
#include <folly/container/EvictingCacheMap.h>
|
||||||
#include <folly/container/F14Map.h>
|
|
||||||
#include <folly/stats/Histogram.h>
|
#include <folly/stats/Histogram.h>
|
||||||
#include <folly/system/ThreadName.h>
|
#include <folly/system/ThreadName.h>
|
||||||
|
|
||||||
|
#include <parallel_hashmap/phmap.h>
|
||||||
|
|
||||||
#include <dwarfs/logger.h>
|
#include <dwarfs/logger.h>
|
||||||
#include <dwarfs/mmif.h>
|
#include <dwarfs/mmif.h>
|
||||||
#include <dwarfs/performance_monitor.h>
|
#include <dwarfs/performance_monitor.h>
|
||||||
@ -783,18 +784,19 @@ class block_cache_ final : public block_cache::impl {
|
|||||||
|
|
||||||
using lru_type =
|
using lru_type =
|
||||||
folly::EvictingCacheMap<size_t, std::shared_ptr<cached_block>>;
|
folly::EvictingCacheMap<size_t, std::shared_ptr<cached_block>>;
|
||||||
|
template <typename Key, typename Value>
|
||||||
|
using fast_map_type = phmap::flat_hash_map<Key, Value>;
|
||||||
|
|
||||||
mutable std::mutex mx_;
|
mutable std::mutex mx_;
|
||||||
mutable lru_type cache_;
|
mutable lru_type cache_;
|
||||||
mutable folly::F14FastMap<size_t,
|
mutable fast_map_type<size_t, std::vector<std::weak_ptr<block_request_set>>>
|
||||||
std::vector<std::weak_ptr<block_request_set>>>
|
|
||||||
active_;
|
active_;
|
||||||
std::thread tidy_thread_;
|
std::thread tidy_thread_;
|
||||||
std::condition_variable tidy_cond_;
|
std::condition_variable tidy_cond_;
|
||||||
bool tidy_running_{false};
|
bool tidy_running_{false};
|
||||||
|
|
||||||
mutable std::mutex mx_dec_;
|
mutable std::mutex mx_dec_;
|
||||||
mutable folly::F14FastMap<size_t, std::weak_ptr<block_request_set>>
|
mutable fast_map_type<size_t, std::weak_ptr<block_request_set>>
|
||||||
decompressing_;
|
decompressing_;
|
||||||
|
|
||||||
mutable std::atomic<size_t> blocks_created_{0};
|
mutable std::atomic<size_t> blocks_created_{0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user