diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-03-14 10:56:44 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-03-14 10:56:44 +0000 |
commit | a874b7f238e04c7d6a83b0ebbb404a1a54c4cb03 (patch) | |
tree | 24ec3fbf42b5e16cbffb783c3f61c2abcc835174 /searchlib | |
parent | e1c88ac18ff874a509b67540bb99b223d5bc5c07 (diff) |
Enable free lists when each dense tensor use the same amount of memory (all dimensions are bound).
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp | 4 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 2e339a069b6..bd814b0ad32 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -307,6 +307,10 @@ Fixture::testSaveLoad() void Fixture::testCompaction() { + if (_useDenseTensorAttribute && _denseTensors && !_cfg.tensorType().is_abstract()) { + LOG(info, "Skipping compaction test for tensor '%s' which is using free-lists", _cfg.tensorType().to_spec().c_str()); + return; + } ensureSpace(4); Tensor::UP emptytensor = _tensorAttr->getEmptyTensor(); Tensor::UP emptyxytensor = createTensor({}, {"x", "y"}); diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp index 18c52c21206..eae0f5364b8 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_store.cpp @@ -79,6 +79,10 @@ DenseTensorStore::DenseTensorStore(const ValueType &type) _emptyCells.resize(_tensorSizeCalc._numBoundCells, 0.0); _store.addType(&_bufferType); _store.initActiveBuffers(); + if (_tensorSizeCalc._numUnboundDims == 0) { + // In this case each tensor use the same amount of memory and we can re-use previously allocated raw buffers by using free lists. + _store.enableFreeLists(); + } } DenseTensorStore::~DenseTensorStore() @@ -120,7 +124,7 @@ DenseTensorStore::allocRawBuffer(size_t numCells) { size_t bufSize = numCells * _tensorSizeCalc._cellSize; size_t alignedBufSize = alignedSize(numCells); - auto result = _concreteStore.rawAllocator<char>(_typeId).alloc(alignedBufSize); + auto result = _concreteStore.freeListRawAllocator<char>(_typeId).alloc(alignedBufSize); clearPadAreaAfterBuffer(result.data, bufSize, alignedBufSize, unboundDimSizesSize()); return result; } |