summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-09 05:22:40 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-09 05:22:40 +0000
commitcb57afc766dbfd1edade668d2b0bb5a0802b4668 (patch)
treeda5e8cdcda555389927bb669b0d87ac78b5002ec /vespalib
parent3306991027b5dace7fb658eccc6d58bc58487070 (diff)
Automatically switch to mmap for large allocations.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/shared_string_repo.h14
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 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 <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);