summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2021-02-12 23:04:51 +0100
committerTor Egge <Tor.Egge@broadpark.no>2021-02-15 13:40:57 +0100
commitd0580a51332db9e2f8e2d24799ef22942dc16abb (patch)
treef4249ab1c463bf7246957786d6a5097c37d0e578 /searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
parent5e6d0030e9bc9d4b61327ee62ae441a7322fc811 (diff)
Use mmap file allocator in dense tensor attribute if huge flag is
set in config.
Diffstat (limited to 'searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp')
-rw-r--r--searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
index f1d910f2635..8efccf9b51b 100644
--- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
+++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
@@ -26,6 +26,7 @@
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/util/mmap_file_allocator_factory.h>
#include <vespa/searchlib/util/bufferwriter.h>
#include <vespa/log/log.h>
@@ -256,6 +257,7 @@ struct FixtureTraits {
bool use_direct_tensor_attribute = false;
bool enable_hnsw_index = false;
bool use_mock_index = false;
+ bool use_mmap_file_allocator = false;
FixtureTraits dense() && {
use_dense_tensor_attribute = true;
@@ -263,6 +265,11 @@ struct FixtureTraits {
return *this;
}
+ FixtureTraits mmap_file_allocator() && {
+ use_mmap_file_allocator = true;
+ return *this;
+ }
+
FixtureTraits hnsw() && {
use_dense_tensor_attribute = true;
enable_hnsw_index = true;
@@ -327,6 +334,9 @@ struct Fixture {
if (_cfg.tensorType().is_dense()) {
_denseTensors = true;
}
+ if (_traits.use_mmap_file_allocator) {
+ _cfg.setHuge(true);
+ }
if (_traits.use_mock_index) {
_index_factory = std::make_unique<MockNearestNeighborIndexFactory>();
} else {
@@ -998,4 +1008,17 @@ TEST_F("NN blueprint handles strong filter triggering brute force search", Neare
EXPECT_FALSE(bp->may_approximate());
}
+TEST("Dense tensor attribute with huge flag uses mmap file allocator")
+{
+ vespalib::string basedir("mmap-file-allocator-factory-dir");
+ vespalib::alloc::MmapFileAllocatorFactory::instance().setup(basedir);
+ {
+ Fixture f(vec_2d_spec, FixtureTraits().dense().mmap_file_allocator());
+ vespalib::string allocator_dir(basedir + "/0.my_attr");
+ EXPECT_TRUE(vespalib::isDirectory(allocator_dir));
+ }
+ vespalib::alloc::MmapFileAllocatorFactory::instance().setup("");
+ vespalib::rmdir(basedir, true);
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }