aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-08 22:02:29 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-08 22:02:29 +0000
commitbcd1eb0bc951312509cccddd5efbc19bb939e703 (patch)
treed73dd0c9ac608216614c8bd67307cac2c07ac99a /vespalib
parent1ae60f5ffb0500ae6ccd93779a28edef948cc503 (diff)
vector of string_id tends to become very large. Use mmap allocation automatically.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/util/shared_string_repo.h4
-rw-r--r--vespalib/src/vespa/vespalib/util/string_id.h5
3 files changed, 9 insertions, 6 deletions
diff --git a/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp b/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp
index 81c8271f755..5b267c3b9e9 100644
--- a/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp
+++ b/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp
@@ -101,8 +101,8 @@ std::unique_ptr<Handles> copy_strong_handles(const Handles &handles) {
return result;
}
-std::unique_ptr<std::vector<string_id>> make_weak_handles(const Handles &handles) {
- return std::make_unique<std::vector<string_id>>(handles.view());
+std::unique_ptr<StringIdVector> make_weak_handles(const Handles &handles) {
+ return std::make_unique<StringIdVector>(handles.view());
}
//-----------------------------------------------------------------------------
@@ -202,7 +202,7 @@ struct Fixture {
std::vector<vespalib::string> get_direct_result;
std::unique_ptr<Handles> strong;
std::unique_ptr<Handles> strong_copy;
- std::unique_ptr<std::vector<string_id>> weak;
+ std::unique_ptr<StringIdVector> weak;
auto copy_strings_task = [&](){ copy_strings_result = copy_strings(work); };
auto copy_and_hash_task = [&](){ copy_and_hash_result = copy_and_hash(work); };
auto local_enum_task = [&](){ local_enum_result = local_enum(work); };
diff --git a/vespalib/src/vespa/vespalib/util/shared_string_repo.h b/vespalib/src/vespa/vespalib/util/shared_string_repo.h
index ec65b942d88..d5faa0dfb0d 100644
--- a/vespalib/src/vespa/vespalib/util/shared_string_repo.h
+++ b/vespalib/src/vespa/vespalib/util/shared_string_repo.h
@@ -291,7 +291,7 @@ public:
// A collection of string handles with ownership
class Handles {
private:
- std::vector<string_id> _handles;
+ StringIdVector _handles;
public:
Handles();
Handles(Handles &&rhs);
@@ -309,7 +309,7 @@ public:
string_id id = _repo.copy(handle);
_handles.push_back(id);
}
- const std::vector<string_id> &view() const { return _handles; }
+ const StringIdVector &view() const { return _handles; }
};
};
diff --git a/vespalib/src/vespa/vespalib/util/string_id.h b/vespalib/src/vespa/vespalib/util/string_id.h
index 7a72feee64a..7fec1da0bb8 100644
--- a/vespalib/src/vespa/vespalib/util/string_id.h
+++ b/vespalib/src/vespa/vespalib/util/string_id.h
@@ -2,7 +2,8 @@
#pragma once
-#include <cstdint>
+#include <vespa/vespalib/stllike/allocator.h>
+#include <vector>
namespace vespalib {
@@ -38,4 +39,6 @@ public:
constexpr bool operator!=(const string_id &rhs) const noexcept { return (_id != rhs._id); }
};
+using StringIdVector = std::vector<string_id, vespalib::allocator_large<string_id>>;
+
}