summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-06-19 13:08:42 +0200
committerGitHub <noreply@github.com>2023-06-19 13:08:42 +0200
commitf857700a50800d418426f3827b744a501d55249f (patch)
tree10f7d5e8352b8f7b66e86ac56b5ac7f1ce55000d
parentbab3e2b4130ba1461efa4280261693d1b34715e6 (diff)
parentd40bde66cee3c19f474b64683b7856c0e1ba177f (diff)
Merge pull request #27478 from vespa-engine/toregge/switch-to-dynamic-type-mapper-for-multi-value-mapping
Switch to dynamic type mapper for multi value mapping.
-rw-r--r--searchlib/src/tests/attribute/attribute_test.cpp24
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h10
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multi_value_mapping.hpp7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multi_value_mapping_read_view.h5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multivalueattribute.hpp2
6 files changed, 31 insertions, 19 deletions
diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp
index 870562355d1..a78dbabe4e3 100644
--- a/searchlib/src/tests/attribute/attribute_test.cpp
+++ b/searchlib/src/tests/attribute/attribute_test.cpp
@@ -1089,8 +1089,8 @@ AttributeTest::testArray()
{
AttributePtr ptr = createAttribute("a-int32", Config(BasicType::INT32, CollectionType::ARRAY));
ptr->updateStat(true);
- EXPECT_EQ(495664u, ptr->getStatus().getAllocated());
- EXPECT_EQ(487904u, ptr->getStatus().getUsed());
+ EXPECT_EQ(297952u, ptr->getStatus().getAllocated());
+ EXPECT_EQ(256092u, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<IntegerAttribute, AttributeVector::largeint_t>(ptr, values);
}
@@ -1099,8 +1099,8 @@ AttributeTest::testArray()
cfg.setFastSearch(true);
AttributePtr ptr = createAttribute("flags", cfg);
ptr->updateStat(true);
- EXPECT_EQ(495664u, ptr->getStatus().getAllocated());
- EXPECT_EQ(487904u, ptr->getStatus().getUsed());
+ EXPECT_EQ(297952u, ptr->getStatus().getAllocated());
+ EXPECT_EQ(256092u, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<IntegerAttribute, AttributeVector::largeint_t>(ptr, values);
}
@@ -1109,8 +1109,8 @@ AttributeTest::testArray()
cfg.setFastSearch(true);
AttributePtr ptr = createAttribute("a-fs-int32", cfg);
ptr->updateStat(true);
- EXPECT_EQ(852300u, ptr->getStatus().getAllocated());
- EXPECT_EQ(589556u, ptr->getStatus().getUsed());
+ EXPECT_EQ(654588u, ptr->getStatus().getAllocated());
+ EXPECT_EQ(357744u, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<IntegerAttribute, AttributeVector::largeint_t>(ptr, values);
}
@@ -1128,8 +1128,8 @@ AttributeTest::testArray()
cfg.setFastSearch(true);
AttributePtr ptr = createAttribute("a-fs-float", cfg);
ptr->updateStat(true);
- EXPECT_EQ(852300u, ptr->getStatus().getAllocated());
- EXPECT_EQ(589556u, ptr->getStatus().getUsed());
+ EXPECT_EQ(654588u, ptr->getStatus().getAllocated());
+ EXPECT_EQ(357744u, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<FloatingPointAttribute, double>(ptr, values);
}
@@ -1140,8 +1140,8 @@ AttributeTest::testArray()
{
AttributePtr ptr = createAttribute("a-string", Config(BasicType::STRING, CollectionType::ARRAY));
ptr->updateStat(true);
- EXPECT_EQ(607968u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
- EXPECT_EQ(540748u + sizeof_large_string_entry, ptr->getStatus().getUsed());
+ EXPECT_EQ(410256u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
+ EXPECT_EQ(308936u + sizeof_large_string_entry, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<StringAttribute, string>(ptr, values);
}
@@ -1150,8 +1150,8 @@ AttributeTest::testArray()
cfg.setFastSearch(true);
AttributePtr ptr = createAttribute("afs-string", cfg);
ptr->updateStat(true);
- EXPECT_EQ(858176u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
- EXPECT_EQ(592480u + sizeof_large_string_entry, ptr->getStatus().getUsed());
+ EXPECT_EQ(660464u + sizeof_large_string_entry, ptr->getStatus().getAllocated());
+ EXPECT_EQ(360668u + sizeof_large_string_entry, ptr->getStatus().getUsed());
addDocs(ptr, numDocs);
testArray<StringAttribute, string>(ptr, values);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp
index 3c1fc15088f..153f4148a64 100644
--- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.cpp
@@ -5,6 +5,8 @@
#include "i_enum_store.h"
#include <vespa/searchcommon/attribute/multivalue.h>
#include <vespa/vespalib/datastore/atomic_entry_ref.h>
+#include <vespa/vespalib/datastore/array_store_dynamic_type_mapper.hpp>
+#include <vespa/vespalib/datastore/dynamic_array_buffer_type.hpp>
#include <vespa/vespalib/datastore/buffer_type.hpp>
#include <vespa/vespalib/util/array.hpp>
diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h
index 4fce64aa762..0725a574aa0 100644
--- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h
+++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h
@@ -5,6 +5,8 @@
#include "multi_value_mapping_base.h"
#include "multi_value_mapping_read_view.h"
#include <vespa/vespalib/datastore/array_store.h>
+#include <vespa/vespalib/datastore/array_store_dynamic_type_mapper.h>
+#include <vespa/vespalib/datastore/dynamic_array_buffer_type.h>
#include <vespa/vespalib/util/address_space.h>
namespace search::attribute {
@@ -19,9 +21,13 @@ public:
using MultiValueType = ElemT;
using RefType = RefT;
using ReadView = MultiValueMappingReadView<ElemT, RefT>;
+
+ static constexpr double array_store_grow_factor = 1.03;
+ static constexpr uint32_t array_store_max_type_id = 300;
private:
using ArrayRef = vespalib::ArrayRef<ElemT>;
- using ArrayStore = vespalib::datastore::ArrayStore<ElemT, RefT>;
+ using ArrayStoreTypeMapper = vespalib::datastore::ArrayStoreDynamicTypeMapper<ElemT>;
+ using ArrayStore = vespalib::datastore::ArrayStore<ElemT, RefT, ArrayStoreTypeMapper>;
using generation_t = vespalib::GenerationHandler::generation_t;
using ConstArrayRef = vespalib::ConstArrayRef<ElemT>;
@@ -70,7 +76,7 @@ public:
void set_compaction_spec(vespalib::datastore::CompactionSpec compaction_spec) noexcept { _store.set_compaction_spec(compaction_spec); }
- static vespalib::datastore::ArrayStoreConfig optimizedConfigForHugePage(size_t maxSmallArraySize,
+ static vespalib::datastore::ArrayStoreConfig optimizedConfigForHugePage(size_t max_type_id,
size_t hugePageSize,
size_t smallPageSize,
size_t min_num_entries_for_new_buffer,
diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.hpp b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.hpp
index ab68bea58cc..ab1f32e8dc2 100644
--- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.hpp
@@ -12,7 +12,7 @@ MultiValueMapping<ElemT,RefT>::MultiValueMapping(const vespalib::datastore::Arra
const vespalib::GrowStrategy &gs,
std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator)
: MultiValueMappingBase(gs, ArrayStore::getGenerationHolderLocation(_store), memory_allocator),
- _store(storeCfg, std::move(memory_allocator))
+ _store(storeCfg, std::move(memory_allocator), ArrayStoreTypeMapper(storeCfg.maxSmallArrayTypeId(), array_store_grow_factor))
{
}
@@ -65,14 +65,15 @@ MultiValueMapping<ElemT, RefT>::getAddressSpaceUsage() const {
template <typename ElemT, typename RefT>
vespalib::datastore::ArrayStoreConfig
-MultiValueMapping<ElemT, RefT>::optimizedConfigForHugePage(size_t maxSmallArraySize,
+MultiValueMapping<ElemT, RefT>::optimizedConfigForHugePage(size_t max_type_id,
size_t hugePageSize,
size_t smallPageSize,
size_t min_num_entries_for_new_buffer,
float allocGrowFactor,
bool enable_free_lists)
{
- auto result = ArrayStore::optimizedConfigForHugePage(maxSmallArraySize, hugePageSize, smallPageSize, min_num_entries_for_new_buffer, allocGrowFactor);
+ ArrayStoreTypeMapper mapper(max_type_id, array_store_grow_factor);
+ auto result = ArrayStore::optimizedConfigForHugePage(max_type_id, mapper, hugePageSize, smallPageSize, min_num_entries_for_new_buffer, allocGrowFactor);
result.enable_free_lists(enable_free_lists);
return result;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_read_view.h b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_read_view.h
index 609989208c3..1f9875133d3 100644
--- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_read_view.h
+++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_read_view.h
@@ -4,6 +4,8 @@
#include <vespa/vespalib/datastore/atomic_entry_ref.h>
#include <vespa/vespalib/datastore/array_store.h>
+#include <vespa/vespalib/datastore/array_store_dynamic_type_mapper.h>
+#include <vespa/vespalib/datastore/dynamic_array_buffer_type.h>
#include <vespa/vespalib/util/address_space.h>
namespace search::attribute {
@@ -16,7 +18,8 @@ class MultiValueMappingReadView
{
using AtomicEntryRef = vespalib::datastore::AtomicEntryRef;
using Indices = vespalib::ConstArrayRef<AtomicEntryRef>;
- using ArrayStore = vespalib::datastore::ArrayStore<ElemT, RefT>;
+ using ArrayStoreTypeMapper = vespalib::datastore::ArrayStoreDynamicTypeMapper<ElemT>;
+ using ArrayStore = vespalib::datastore::ArrayStore<ElemT, RefT, ArrayStoreTypeMapper>;
Indices _indices;
const ArrayStore* _store;
diff --git a/searchlib/src/vespa/searchlib/attribute/multivalueattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multivalueattribute.hpp
index aea7e57897f..d8ada97fa2c 100644
--- a/searchlib/src/vespa/searchlib/attribute/multivalueattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multivalueattribute.hpp
@@ -25,7 +25,7 @@ MultiValueAttribute<B, M>::
MultiValueAttribute(const vespalib::string &baseFileName,
const AttributeVector::Config &cfg)
: B(baseFileName, cfg),
- _mvMapping(MultiValueMapping::optimizedConfigForHugePage(1023,
+ _mvMapping(MultiValueMapping::optimizedConfigForHugePage(MultiValueMapping::array_store_max_type_id,
vespalib::alloc::MemoryAllocator::HUGEPAGE_SIZE,
vespalib::alloc::MemoryAllocator::PAGE_SIZE,
8 * 1024,