From cb57afc766dbfd1edade668d2b0bb5a0802b4668 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 9 Feb 2022 05:22:40 +0000 Subject: Automatically switch to mmap for large allocations. --- vespalib/src/vespa/vespalib/util/shared_string_repo.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'vespalib') diff --git a/vespalib/src/vespa/vespalib/util/shared_string_repo.h b/vespalib/src/vespa/vespalib/util/shared_string_repo.h index ec65b942d88..69aeba2ab7e 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 #include #include +#include #include #include #include @@ -95,6 +96,7 @@ private: return (--_ref_cnt == 0); } }; + using EntryVector = std::vector>; 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 &entries; - Equal(const std::vector &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; private: - mutable SpinLock _lock; - std::vector _entries; - uint32_t _free; - HashType _hash; + mutable SpinLock _lock; + EntryVector _entries; + uint32_t _free; + HashType _hash; void make_entries(size_t hint); -- cgit v1.2.3