aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2022-03-28 14:30:33 +0000
committerTor Brede Vekterli <vekterli@yahooinc.com>2022-03-28 14:30:33 +0000
commitd11c7181ef8b80fb20a6b4285da4fe95f577b4ae (patch)
tree549726516e60849d382560ba0db1cd4f4faf6ec7 /searchlib
parent19f950ba81d98904b67fd45c48865754af4b590f (diff)
Let empty entry BufferType sentinel be static instead of global
Avoids issue where a global BufferType with a transitive Alloc instance binds to a null reference allocator since the global allocator instance has not yet been initialized as part of global constructor invocation. Manually hoist empty sentinel ref outside of loops since it might not be obvious to the compiler that the same object is reused over and over.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/tensor/direct_tensor_store.h2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/tensor/streamed_value_store.h2
4 files changed, 6 insertions, 4 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp
index 54f95e1c543..3f2a1bb1969 100644
--- a/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp
@@ -21,9 +21,10 @@ void
DirectTensorStore::TensorBufferType::cleanHold(void* buffer, size_t offset, ElemCount num_elems, CleanContext clean_ctx)
{
TensorSP* elem = static_cast<TensorSP*>(buffer) + offset;
+ const auto& empty = empty_entry();
for (size_t i = 0; i < num_elems; ++i) {
clean_ctx.extraBytesCleaned((*elem)->get_memory_usage().allocatedBytes());
- *elem = _emptyEntry;
+ *elem = empty;
++elem;
}
}
diff --git a/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.h b/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.h
index 776920ab930..1f112f1ea28 100644
--- a/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.h
+++ b/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.h
@@ -24,7 +24,7 @@ private:
class TensorBufferType : public vespalib::datastore::BufferType<TensorSP> {
private:
using ParentType = BufferType<TensorSP>;
- using ParentType::_emptyEntry;
+ using ParentType::empty_entry;
using CleanContext = typename ParentType::CleanContext;
public:
TensorBufferType();
diff --git a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp
index 2e6d771a870..a668387e5bd 100644
--- a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp
@@ -166,9 +166,10 @@ void
StreamedValueStore::TensorBufferType::cleanHold(void* buffer, size_t offset, ElemCount num_elems, CleanContext clean_ctx)
{
TensorEntry::SP* elem = static_cast<TensorEntry::SP*>(buffer) + offset;
+ const auto& empty = empty_entry();
for (size_t i = 0; i < num_elems; ++i) {
clean_ctx.extraBytesCleaned((*elem)->get_memory_usage().allocatedBytes());
- *elem = _emptyEntry;
+ *elem = empty;
++elem;
}
}
diff --git a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.h b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.h
index 7d83e9f3335..29201dc0e61 100644
--- a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.h
+++ b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.h
@@ -51,7 +51,7 @@ private:
class TensorBufferType : public vespalib::datastore::BufferType<TensorEntry::SP> {
private:
using ParentType = BufferType<TensorEntry::SP>;
- using ParentType::_emptyEntry;
+ using ParentType::empty_entry;
using CleanContext = typename ParentType::CleanContext;
public:
TensorBufferType() noexcept;