diff options
author | HÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com> | 2022-02-09 10:29:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-09 10:29:42 +0100 |
commit | d5b0efcc26d2d888fa455fbfed1d2b0bb709c211 (patch) | |
tree | 3a3a26f632d5e9f2909a7aa0c55e4191e889b555 | |
parent | 0eeda7e810af1aeb56773b5dec49843705b61f78 (diff) | |
parent | cb57afc766dbfd1edade668d2b0bb5a0802b4668 (diff) |
Merge pull request #21115 from vespa-engine/balder/use-mmap-for-large-vectors-5
Automatically switch to mmap for large allocations.
-rw-r--r-- | vespalib/src/vespa/vespalib/util/shared_string_repo.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/vespalib/src/vespa/vespalib/util/shared_string_repo.h b/vespalib/src/vespa/vespalib/util/shared_string_repo.h index d5faa0dfb0d..7ba59937c7c 100644 --- a/vespalib/src/vespa/vespalib/util/shared_string_repo.h +++ b/vespalib/src/vespa/vespalib/util/shared_string_repo.h @@ -8,6 +8,7 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/stllike/identity.h> +#include <vespa/vespalib/stllike/allocator.h> #include <vespa/vespalib/stllike/hashtable.hpp> #include <xxhash.h> #include <mutex> @@ -95,6 +96,7 @@ private: return (--_ref_cnt == 0); } }; + using EntryVector = std::vector<Entry, allocator_large<Entry>>; struct Key { uint32_t idx; uint32_t hash; @@ -104,8 +106,8 @@ private: uint32_t operator()(const AltKey &key) const { return key.hash; } }; struct Equal { - const std::vector<Entry> &entries; - Equal(const std::vector<Entry> &entries_in) : entries(entries_in) {} + const EntryVector &entries; + Equal(const EntryVector &entries_in) : entries(entries_in) {} Equal(const Equal &rhs) = default; bool operator()(const Key &a, const Key &b) const { return (a.idx == b.idx); } bool operator()(const Key &a, const AltKey &b) const { return ((a.hash == b.hash) && (entries[a.idx].str() == b.str)); } @@ -113,10 +115,10 @@ private: using HashType = hashtable<Key,Key,Hash,Equal,Identity,hashtable_base::and_modulator>; private: - mutable SpinLock _lock; - std::vector<Entry> _entries; - uint32_t _free; - HashType _hash; + mutable SpinLock _lock; + EntryVector _entries; + uint32_t _free; + HashType _hash; void make_entries(size_t hint); |