Merge pull request #108 from decster/prefetch-hash

Add prefetch_hash for parrallel hash map/set
This commit is contained in:
Gregory Popovitch
2021-09-07 07:28:32 -04:00
committed by GitHub
+6 -4
View File
@@ -3206,16 +3206,18 @@ public:
// NOTE: This is a very low level operation and should not be used without
// specific benchmarks indicating its importance.
// --------------------------------------------------------------------
template <class K = key_type>
void prefetch(const key_arg<K>& key) const {
(void)key;
size_t hashval = this->hash(key);
void prefetch_hash(size_t hashval) const {
const Inner& inner = sets_[subidx(hashval)];
const auto& set = inner.set_;
typename Lockable::SharedLock m(const_cast<Inner&>(inner));
set.prefetch_hash(hashval);
}
template <class K = key_type>
void prefetch(const key_arg<K>& key) const {
prefetch_hash(this->hash(key));
}
// The API of find() has two extensions.
//
// 1. The hash can be passed by the user. It must be equal to the hash of the