diff options
Diffstat (limited to 'searchlib/src/tests')
5 files changed, 88 insertions, 3 deletions
diff --git a/searchlib/src/tests/attribute/multi_value_mapping2/multi_value_mapping2_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping2/multi_value_mapping2_test.cpp index 01cc4fd7154..6f0b7fe5e49 100644 --- a/searchlib/src/tests/attribute/multi_value_mapping2/multi_value_mapping2_test.cpp +++ b/searchlib/src/tests/attribute/multi_value_mapping2/multi_value_mapping2_test.cpp @@ -11,6 +11,8 @@ LOG_SETUP("multivaluemapping2_test"); #include <vespa/searchlib/util/rand48.h> #include <vespa/vespalib/stllike/hash_set.h> +using search::datastore::ArrayStoreConfig; + template <typename EntryT> void assertArray(const std::vector<EntryT> &exp, vespalib::ConstArrayRef<EntryT> values) @@ -64,17 +66,18 @@ protected: using MvMapping = search::attribute::MultiValueMapping2<EntryT>; MvMapping _mvMapping; MyAttribute<MvMapping> _attr; + using RefType = typename MvMapping::RefType; using generation_t = vespalib::GenerationHandler::generation_t; public: using ConstArrayRef = vespalib::ConstArrayRef<EntryT>; Fixture(uint32_t maxSmallArraySize) - : _mvMapping(maxSmallArraySize), + : _mvMapping(ArrayStoreConfig(maxSmallArraySize, ArrayStoreConfig::AllocSpec(0, RefType::offsetSize(), 8 * 1024))), _attr(_mvMapping) { } Fixture(uint32_t maxSmallArraySize, size_t minClusters, size_t maxClusters, size_t numClustersForNewBuffer) - : _mvMapping(maxSmallArraySize, minClusters, maxClusters, numClustersForNewBuffer), + : _mvMapping(ArrayStoreConfig(maxSmallArraySize, ArrayStoreConfig::AllocSpec(minClusters, maxClusters, numClustersForNewBuffer))), _attr(_mvMapping) { } diff --git a/searchlib/src/tests/datastore/array_store/array_store_test.cpp b/searchlib/src/tests/datastore/array_store/array_store_test.cpp index 161df30f3cc..39cd458a1da 100644 --- a/searchlib/src/tests/datastore/array_store/array_store_test.cpp +++ b/searchlib/src/tests/datastore/array_store/array_store_test.cpp @@ -53,7 +53,7 @@ struct Fixture ReferenceStore refStore; generation_t generation; Fixture(uint32_t maxSmallArraySize) - : store(maxSmallArraySize), + : store(ArrayStoreConfig(maxSmallArraySize, ArrayStoreConfig::AllocSpec(16, RefT::offsetSize(), 8 * 1024))), refStore(), generation(1) {} diff --git a/searchlib/src/tests/datastore/array_store_config/CMakeLists.txt b/searchlib/src/tests/datastore/array_store_config/CMakeLists.txt new file mode 100644 index 00000000000..465e697553a --- /dev/null +++ b/searchlib/src/tests/datastore/array_store_config/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +vespa_add_executable(searchlib_array_store_config_test_app TEST + SOURCES + array_store_config_test.cpp + DEPENDS + searchlib +) +vespa_add_test(NAME searchlib_array_store_config_test_app COMMAND searchlib_array_store_config_test_app) diff --git a/searchlib/src/tests/datastore/array_store_config/FILES b/searchlib/src/tests/datastore/array_store_config/FILES new file mode 100644 index 00000000000..71f4e3f5b8c --- /dev/null +++ b/searchlib/src/tests/datastore/array_store_config/FILES @@ -0,0 +1 @@ +array_store_config_test.cpp diff --git a/searchlib/src/tests/datastore/array_store_config/array_store_config_test.cpp b/searchlib/src/tests/datastore/array_store_config/array_store_config_test.cpp new file mode 100644 index 00000000000..bc7a446b3b4 --- /dev/null +++ b/searchlib/src/tests/datastore/array_store_config/array_store_config_test.cpp @@ -0,0 +1,73 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/fastos/fastos.h> +#include <vespa/log/log.h> +LOG_SETUP("array_store_config_test"); +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/searchlib/datastore/entryref.h> +#include <vespa/searchlib/datastore/array_store_config.h> + +using namespace search::datastore; +using AllocSpec = ArrayStoreConfig::AllocSpec; + +struct Fixture +{ + using EntryRefType = EntryRefT<18>; + ArrayStoreConfig cfg; + + Fixture(uint32_t maxSmallArraySize, + const AllocSpec &defaultSpec) + : cfg(maxSmallArraySize, defaultSpec) {} + + Fixture(uint32_t maxSmallArraySize, + size_t hugePageSize, + size_t smallPageSize, + size_t minNumArraysForNewBuffer) + : cfg(ArrayStoreConfig::optimizeForHugePage(maxSmallArraySize, hugePageSize, smallPageSize, + sizeof(int), EntryRefType::offsetSize(), + minNumArraysForNewBuffer)) { } + void assertSpec(size_t arraySize, uint32_t numArraysForNewBuffer) { + assertSpec(arraySize, AllocSpec(0, EntryRefType::offsetSize(), numArraysForNewBuffer)); + } + void assertSpec(size_t arraySize, const AllocSpec &expSpec) { + const ArrayStoreConfig::AllocSpec &actSpec = cfg.specForSize(arraySize); + EXPECT_EQUAL(expSpec.minArraysInBuffer, actSpec.minArraysInBuffer); + EXPECT_EQUAL(expSpec.maxArraysInBuffer, actSpec.maxArraysInBuffer); + EXPECT_EQUAL(expSpec.numArraysForNewBuffer, actSpec.numArraysForNewBuffer); + } +}; + +constexpr size_t KB = 1024; +constexpr size_t MB = KB * KB; + +TEST_F("require that default allocation spec is given for all array sizes", Fixture(3, AllocSpec(4, 32, 8))) +{ + EXPECT_EQUAL(3, f.cfg.maxSmallArraySize()); + TEST_DO(f.assertSpec(0, AllocSpec(4, 32, 8))); + TEST_DO(f.assertSpec(1, AllocSpec(4, 32, 8))); + TEST_DO(f.assertSpec(2, AllocSpec(4, 32, 8))); + TEST_DO(f.assertSpec(3, AllocSpec(4, 32, 8))); +} + +TEST_F("require that we can generate config optimized for a given huge page", Fixture(1024, + 2 * MB, + 4 * KB, + 8 * KB)) +{ + EXPECT_EQUAL(1024, f.cfg.maxSmallArraySize()); + TEST_DO(f.assertSpec(0, 8 * KB)); // large arrays + TEST_DO(f.assertSpec(1, 256 * KB)); + TEST_DO(f.assertSpec(2, 256 * KB)); + TEST_DO(f.assertSpec(3, 168 * KB)); + TEST_DO(f.assertSpec(4, 128 * KB)); + TEST_DO(f.assertSpec(5, 100 * KB)); + TEST_DO(f.assertSpec(6, 84 * KB)); + + TEST_DO(f.assertSpec(32, 16 * KB)); + TEST_DO(f.assertSpec(33, 12 * KB)); + TEST_DO(f.assertSpec(42, 12 * KB)); + TEST_DO(f.assertSpec(43, 8 * KB)); + TEST_DO(f.assertSpec(1022, 8 * KB)); + TEST_DO(f.assertSpec(1023, 8 * KB)); +} + +TEST_MAIN() { TEST_RUN_ALL(); } |