aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-02-15 17:15:17 +0100
committerGitHub <noreply@github.com>2023-02-15 17:15:17 +0100
commit6311d48315bf6baced43d8d1a5c2b9308bf543e4 (patch)
treefd06625e60a4b5f530facf6453d548e6d8f2c82a /searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp
parent994c07cb9470017c4855a0d7523a09a5bdca1d88 (diff)
parent5a66f8e7375bafccf365a1448bd2709fea623335 (diff)
Merge pull request #26054 from vespa-engine/toregge/add-exponential-array-size-growth-to-tensor-buffer-type-mapperv8.127.1v8.126.20
Add exponential array size growth to tensor buffer type mapper.
Diffstat (limited to 'searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp
index 6c2ef698dc0..ff39c33fc5d 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp
@@ -26,6 +26,8 @@ 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)
@@ -33,11 +35,11 @@ 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, &_ops),
+ TensorBufferTypeMapper(max_small_subspaces_type_id, mapper_grow_factor, &_ops),
MemoryAllocator::HUGEPAGE_SIZE,
MemoryAllocator::PAGE_SIZE,
8_Ki, ALLOC_GROW_FACTOR),
- std::move(allocator), TensorBufferTypeMapper(max_small_subspaces_type_id, &_ops))
+ std::move(allocator), TensorBufferTypeMapper(max_small_subspaces_type_id, mapper_grow_factor, &_ops))
{
}
@@ -81,7 +83,11 @@ EntryRef
TensorBufferStore::store_tensor(const Value &tensor)
{
uint32_t num_subspaces = tensor.index().size();
- auto array_size = _ops.get_array_size(num_subspaces);
+ auto buffer_size = _ops.get_buffer_size(num_subspaces);
+ auto& mapper = _array_store.get_mapper();
+ auto type_id = mapper.get_type_id(buffer_size);
+ auto array_size = (type_id != 0) ? mapper.get_array_size(type_id) : buffer_size;
+ assert(array_size >= buffer_size);
auto ref = _array_store.allocate(array_size);
auto buf = _array_store.get_writable(ref);
_ops.store_tensor(buf, tensor);