diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-06-26 11:43:09 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-06-26 11:43:09 +0200 |
commit | c4c58a9f8705b7b44584c2eb31f37fd3f6c66322 (patch) | |
tree | 8a8b07eedba387b30758ab9a0d0902f16ebb47f7 | |
parent | 74f39c2bed1f08bf9caf56d989408c96c0140a41 (diff) |
Align grow factor for tensor buffer store with multi value mapping.
5 files changed, 15 insertions, 12 deletions
diff --git a/searchlib/src/tests/tensor/tensor_buffer_store/tensor_buffer_store_test.cpp b/searchlib/src/tests/tensor/tensor_buffer_store/tensor_buffer_store_test.cpp index 0a69d8149ed..b42520aa9e0 100644 --- a/searchlib/src/tests/tensor/tensor_buffer_store/tensor_buffer_store_test.cpp +++ b/searchlib/src/tests/tensor/tensor_buffer_store/tensor_buffer_store_test.cpp @@ -198,7 +198,7 @@ TEST_F(TensorBufferStoreTest, buffer_handles_range_of_subspaces) auto buffer_id = ref.buffer_id(offset_bits); buffers.insert(buffer_id); } - EXPECT_EQ(156u, buffers.size()); + EXPECT_EQ(119u, buffers.size()); uint32_t x = 0; for (auto ref : refs) { auto tensor = store.get_tensor(ref); diff --git a/searchlib/src/tests/tensor/tensor_buffer_type_mapper/tensor_buffer_type_mapper_test.cpp b/searchlib/src/tests/tensor/tensor_buffer_type_mapper/tensor_buffer_type_mapper_test.cpp index 08c0901de01..fc574ba9b2c 100644 --- a/searchlib/src/tests/tensor/tensor_buffer_type_mapper/tensor_buffer_type_mapper_test.cpp +++ b/searchlib/src/tests/tensor/tensor_buffer_type_mapper/tensor_buffer_type_mapper_test.cpp @@ -15,7 +15,7 @@ const vespalib::string tensor_type_2d_mixed_spec("tensor(x{},y[2])"); const vespalib::string float_tensor_type_spec("tensor<float>(y{})"); const vespalib::string tensor_type_dense_spec("tensor(x[2])"); -constexpr double grow_factor = 1.02; +constexpr double grow_factor = 1.03; struct TestParam { @@ -128,10 +128,10 @@ TensorBufferTypeMapperTest::select_type_ids() INSTANTIATE_TEST_SUITE_P(TensorBufferTypeMapperMultiTest, TensorBufferTypeMapperTest, - testing::Values(TestParam("1d", {8, 16, 32, 40, 64}, {1760, 10880, 76896, 555248, 4020512}, tensor_type_sparse_spec), - TestParam("1dfloat", {4, 12, 20, 28, 36}, {1728, 11104, 79168, 572128, 4143664}, float_tensor_type_spec), - TestParam("2d", {8, 24, 40, 56, 80}, {1600, 9184, 63872, 460416, 3332976}, tensor_type_2d_spec), - TestParam("2dmixed", {8, 24, 48, 64, 96}, {1984, 11472, 79824, 575504, 4166208}, tensor_type_2d_mixed_spec), + testing::Values(TestParam("1d", {8, 16, 32, 40, 64}, {2768, 49712, 950768, 18268976, 351101184}, tensor_type_sparse_spec), + TestParam("1dfloat", {4, 12, 20, 28, 36}, {2688, 48896, 937248, 18009808, 346121248}, float_tensor_type_spec), + TestParam("2d", {8, 24, 40, 56, 80}, {2416, 41392, 790112, 15179616, 291726288}, tensor_type_2d_spec), + TestParam("2dmixed", {8, 24, 48, 64, 96}, {3008, 51728, 987632, 18974512, 364657856}, tensor_type_2d_mixed_spec), TestParam("dense", {8, 24}, {}, tensor_type_dense_spec)), testing::PrintToStringParamName()); @@ -152,7 +152,7 @@ TEST_P(TensorBufferTypeMapperTest, large_arrays_grows_exponentially) TEST_P(TensorBufferTypeMapperTest, avoid_array_size_overflow) { - TensorBufferTypeMapper mapper(400, 2.0, &_ops); + TensorBufferTypeMapper mapper(300, 2.0, &_ops); EXPECT_GE(30, mapper.get_max_type_id(1000)); } diff --git a/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp index 51ebc22c269..1e79ca53e68 100644 --- a/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp @@ -16,7 +16,8 @@ namespace search::tensor { SerializedFastValueAttribute::SerializedFastValueAttribute(stringref name, const Config &cfg, const NearestNeighborIndexFactory& index_factory) : TensorAttribute(name, cfg, _tensorBufferStore, index_factory), - _tensorBufferStore(cfg.tensorType(), get_memory_allocator(), 400u) + _tensorBufferStore(cfg.tensorType(), get_memory_allocator(), + TensorBufferStore::array_store_max_type_id) { } diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp index 29f20e27d09..8a7d84010cb 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp @@ -26,8 +26,6 @@ namespace { constexpr float ALLOC_GROW_FACTOR = 0.2; -constexpr double mapper_grow_factor = 1.02; - } TensorBufferStore::TensorBufferStore(const ValueType& tensor_type, std::shared_ptr<MemoryAllocator> allocator, uint32_t max_small_subspaces_type_id) @@ -35,12 +33,12 @@ TensorBufferStore::TensorBufferStore(const ValueType& tensor_type, std::shared_p _tensor_type(tensor_type), _ops(_tensor_type), _array_store(ArrayStoreType::optimizedConfigForHugePage(max_small_subspaces_type_id, - TensorBufferTypeMapper(max_small_subspaces_type_id, mapper_grow_factor, &_ops), + TensorBufferTypeMapper(max_small_subspaces_type_id, array_store_grow_factor, &_ops), MemoryAllocator::HUGEPAGE_SIZE, MemoryAllocator::PAGE_SIZE, vespalib::datastore::ArrayStoreConfig::default_max_buffer_size, 8_Ki, ALLOC_GROW_FACTOR), - std::move(allocator), TensorBufferTypeMapper(max_small_subspaces_type_id, mapper_grow_factor, &_ops)) + std::move(allocator), TensorBufferTypeMapper(max_small_subspaces_type_id, array_store_grow_factor, &_ops)) { } diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.h b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.h index 2e86ff5fb67..3342e9f3d27 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.h +++ b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.h @@ -24,6 +24,10 @@ class TensorBufferStore : public TensorStore TensorBufferOperations _ops; ArrayStoreType _array_store; public: + + static constexpr double array_store_grow_factor = 1.03; + static constexpr uint32_t array_store_max_type_id = 300; + TensorBufferStore(const vespalib::eval::ValueType& tensor_type, std::shared_ptr<vespalib::alloc::MemoryAllocator> allocator, uint32_t max_small_subspaces_type_id); ~TensorBufferStore(); void holdTensor(EntryRef ref) override; |