summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2022-03-28 17:56:58 +0200
committerGitHub <noreply@github.com>2022-03-28 17:56:58 +0200
commit827e0b55a041101de1155671775de182c8965969 (patch)
treeef90b6a562bb3444446acb2a2b9f11ebb251e2af
parent0c6c20f84b33d8e32465acfc0c0c14443fa01228 (diff)
parent19f0ea267927337094b74f1735d4751ae2118bf2 (diff)
Merge pull request #21855 from vespa-engine/toregge/trim-down-rcuvector-interface
Trim down rcuvector interface.
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleenumattribute.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_graph.h2
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp3
-rw-r--r--vespalib/src/vespa/vespalib/util/rcuvector.h3
7 files changed, 12 insertions, 7 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
index 16763ccdc9f..87176721681 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h
@@ -135,7 +135,7 @@ private:
MetaDataView make_meta_data_view() { return vespalib::ConstArrayRef(&_metaDataStore[0], getCommittedDocIdLimit()); }
UnboundMetaDataView acquire_unbound_meta_data_view() const noexcept { return &_metaDataStore.acquire_elem_ref(0); }
- UnboundMetaDataView get_unbound_meta_data_view() const noexcept { return &_metaDataStore[0]; }
+ UnboundMetaDataView get_unbound_meta_data_view() const noexcept { return &_metaDataStore.get_elem_ref(0); } // Called from writer only
public:
typedef TreeType::Iterator Iterator;
diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp
index 11ea58bc124..eebef46284b 100644
--- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping_base.cpp
@@ -25,10 +25,11 @@ MultiValueMappingBase::~MultiValueMappingBase() = default;
MultiValueMappingBase::RefCopyVector
MultiValueMappingBase::getRefCopy(uint32_t size) const {
assert(size <= _indices.size());
+ auto* indices = &_indices.get_elem_ref(0); // Called from writer only
RefCopyVector result;
result.reserve(size);
for (uint32_t lid = 0; lid < size; ++lid) {
- result.push_back(_indices[lid].load_relaxed());
+ result.push_back(indices[lid].load_relaxed());
}
return result;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
index a9743990626..2d8d4c4858b 100644
--- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp
@@ -337,10 +337,11 @@ ReferenceAttribute::IndicesCopyVector
ReferenceAttribute::getIndicesCopy(uint32_t size) const
{
assert(size <= _indices.size());
+ auto* indices = &_indices.get_elem_ref(0); // Called from writer only
IndicesCopyVector result;
result.reserve(size);
for (uint32_t i = 0; i < size; ++i) {
- result.push_back(_indices[i].load_relaxed());
+ result.push_back(indices[i].load_relaxed());
}
return result;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.cpp
index b5de652fbe2..b671a23bbe7 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.cpp
@@ -41,10 +41,11 @@ SingleValueEnumAttributeBase::EnumIndexCopyVector
SingleValueEnumAttributeBase::getIndicesCopy(uint32_t size) const
{
assert(size <= _enumIndices.size());
+ auto* enum_indices = &_enumIndices.get_elem_ref(0); // Called from writer only
EnumIndexCopyVector result;
result.reserve(size);
for (uint32_t lid = 0; lid < size; ++lid) {
- result.push_back(_enumIndices[lid].load_relaxed());
+ result.push_back(enum_indices[lid].load_relaxed());
}
return result;
}
diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h b/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h
index 726abb8141d..06482c075cb 100644
--- a/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h
+++ b/searchlib/src/vespa/searchlib/tensor/hnsw_graph.h
@@ -56,7 +56,7 @@ struct HnswGraph {
void trim_node_refs_size();
NodeRef get_node_ref(uint32_t docid) const {
- return node_refs[docid].load_relaxed();
+ return node_refs.get_elem_ref(docid).load_relaxed(); // Called from writer only
}
NodeRef acquire_node_ref(uint32_t docid) const {
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
index 112396fd3fb..89f54eacc09 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
@@ -269,10 +269,11 @@ TensorAttribute::getRefCopy() const
{
uint32_t size = getCommittedDocIdLimit();
assert(size <= _refVector.size());
+ auto* ref_vector = &_refVector.get_elem_ref(0); // Called from writer only
RefCopyVector result;
result.reserve(size);
for (uint32_t i = 0; i < size; ++i) {
- result.push_back(_refVector[i].load_relaxed());
+ result.push_back(ref_vector[i].load_relaxed());
}
return result;
}
diff --git a/vespalib/src/vespa/vespalib/util/rcuvector.h b/vespalib/src/vespa/vespalib/util/rcuvector.h
index d2d0a946b91..fd0a7de441a 100644
--- a/vespalib/src/vespa/vespalib/util/rcuvector.h
+++ b/vespalib/src/vespa/vespalib/util/rcuvector.h
@@ -120,7 +120,6 @@ public:
size_t capacity() const { return _data.capacity(); }
void clear() { _data.clear(); }
T & operator[](size_t i) { return _data[i]; }
- const T & operator[](size_t i) const { return _data[i]; }
/*
* Readers holding a generation guard can call acquire_elem_ref(i)
* to get a const reference to element i. Array bound must be handled
@@ -128,6 +127,8 @@ public:
*/
const T& acquire_elem_ref(size_t i) const noexcept { return *(_vector_start.load(std::memory_order_acquire) + i); }
+ const T& get_elem_ref(size_t i) const noexcept { return _data[i]; } // Called from writer only
+
void reset();
void shrink(size_t newSize) __attribute__((noinline));
void replaceVector(ArrayType replacement);