diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-11-14 08:49:45 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-11-14 08:49:45 +0000 |
commit | 3e8c96fcba038b3b68f75073fbe516912d169311 (patch) | |
tree | c54a28883ff7f7b29ba111234498758478d36477 /searchlib/src/tests/attribute | |
parent | 03d90c743ae83cfea09be55cb7f1787aa8c8453b (diff) |
Enable free lists for multi-value mapping used in all multi-value attributes.
This should reduce the need for compaction which is CPU intensive for some applications.
Diffstat (limited to 'searchlib/src/tests/attribute')
3 files changed, 40 insertions, 10 deletions
diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index ce1344f5c26..f402f536ae2 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -2241,7 +2241,22 @@ void testNamePrefix() { EXPECT_EQUAL("sfsint32_pc", vS2->getNamePrefix()); EXPECT_EQUAL("sfsint32_pc.xyz.abc", vSS1->getName()); EXPECT_EQUAL("sfsint32_pc", vSS1->getNamePrefix()); +} + +class MyMultiValueAttribute : public ArrayStringAttribute { +public: + MyMultiValueAttribute(const vespalib::string& name) + : ArrayStringAttribute(name, Config(BasicType::STRING, CollectionType::ARRAY)) + { + } + bool has_free_lists_enabled() const { return this->_mvMapping.has_free_lists_enabled(); } +}; +void +test_multi_value_mapping_has_free_lists_enabled() +{ + MyMultiValueAttribute attr("mvtest"); + EXPECT_TRUE(attr.has_free_lists_enabled()); } void @@ -2292,6 +2307,7 @@ int AttributeTest::Main() testReaderDuringLastUpdate(); TEST_DO(testPendingCompaction()); TEST_DO(testNamePrefix()); + test_multi_value_mapping_has_free_lists_enabled(); deleteDataDirs(); TEST_DONE(); diff --git a/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp b/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp index c3453783e38..cd2646bbaaf 100644 --- a/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp +++ b/searchlib/src/tests/attribute/compaction/attribute_compaction_test.cpp @@ -174,9 +174,9 @@ TEST_F("Test that no compaction of int8 array attribute increases address space f.populate(range1, 1000); f.hammer(range2, 101); AddressSpace afterSpace = f.getMultiValueAddressSpaceUsage("after"); - // 100 * 1000 dead arrays due to new values for docids + // Only 1000 dead arrays (due to new values for docids) as free lists are used. // 1 reserved array accounted as dead - EXPECT_EQUAL(100001u, afterSpace.dead()); + EXPECT_EQUAL(1001u, afterSpace.dead()); } TEST_F("Test that compaction of int8 array attribute limits address space usage", Fixture(compactAddressSpaceAttributeConfig(true))) diff --git a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp index 9bbcd71f59d..2f74e9d31f6 100644 --- a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp +++ b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp @@ -80,17 +80,19 @@ public: _maxSmallArraySize() { } - void setup(uint32_t maxSmallArraySize) { - _mvMapping = std::make_unique<MvMapping>(ArrayStoreConfig(maxSmallArraySize, - ArrayStoreConfig::AllocSpec(0, RefType::offsetSize(), 8 * 1024, - ALLOC_GROW_FACTOR))); + void setup(uint32_t maxSmallArraySize, bool enable_free_lists = true) { + ArrayStoreConfig config(maxSmallArraySize, + ArrayStoreConfig::AllocSpec(0, RefType::offsetSize(), 8 * 1024, ALLOC_GROW_FACTOR)); + config.enable_free_lists(enable_free_lists); + _mvMapping = std::make_unique<MvMapping>(config); _attr = std::make_unique<AttributeType>(*_mvMapping); _maxSmallArraySize = maxSmallArraySize; } - void setup(uint32_t maxSmallArraySize, size_t minArrays, size_t maxArrays, size_t numArraysForNewBuffer) { - _mvMapping = std::make_unique<MvMapping>(ArrayStoreConfig(maxSmallArraySize, - ArrayStoreConfig::AllocSpec(minArrays, maxArrays, numArraysForNewBuffer, - ALLOC_GROW_FACTOR))); + void setup(uint32_t maxSmallArraySize, size_t minArrays, size_t maxArrays, size_t numArraysForNewBuffer, bool enable_free_lists = true) { + ArrayStoreConfig config(maxSmallArraySize, + ArrayStoreConfig::AllocSpec(minArrays, maxArrays, numArraysForNewBuffer, ALLOC_GROW_FACTOR)); + config.enable_free_lists(enable_free_lists); + _mvMapping = std::make_unique<MvMapping>(config); _attr = std::make_unique<AttributeType>(*_mvMapping); _maxSmallArraySize = maxSmallArraySize; } @@ -307,6 +309,18 @@ TEST_F(IntMappingTest, test_that_replace_works) EXPECT_EQ(4u, getTotalValueCnt()); } +TEST_F(IntMappingTest, test_that_free_lists_can_be_enabled) +{ + setup(3, true); + EXPECT_TRUE(_mvMapping->has_free_lists_enabled()); +} + +TEST_F(IntMappingTest, test_that_free_lists_can_be_disabled) +{ + setup(3, false); + EXPECT_FALSE(_mvMapping->has_free_lists_enabled()); +} + TEST_F(CompactionIntMappingTest, test_that_compaction_works) { setup(3, 64, 512, 129); |