From 0f336eff19a696488acf8009525a4968d9c95fe6 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Sep 2023 20:47:08 +0000 Subject: Use the stored index into the BucketInfoList for direct lookup. --- storage/src/vespa/storage/bucketdb/bucketinfo.hpp | 2 +- storage/src/vespa/storage/distributor/activecopy.cpp | 5 ++--- storage/src/vespa/storage/distributor/activecopy.h | 4 ++-- storage/src/vespa/storage/distributor/statecheckers.cpp | 13 +++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'storage') diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.hpp b/storage/src/vespa/storage/bucketdb/bucketinfo.hpp index d6e99bd3934..a390a747d67 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.hpp +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.hpp @@ -155,7 +155,7 @@ BucketInfoBase::getRef(uint16_t node) const noexcept { return &n - &_nodes[0]; } } - return 0; + return 0xffff; // Not found signal } template diff --git a/storage/src/vespa/storage/distributor/activecopy.cpp b/storage/src/vespa/storage/distributor/activecopy.cpp index 187c3a138ed..05a6ca59612 100644 --- a/storage/src/vespa/storage/distributor/activecopy.cpp +++ b/storage/src/vespa/storage/distributor/activecopy.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include namespace std { @@ -153,8 +152,8 @@ ActiveCopy::calculate(const Node2Index & idealState, const lib::Distribution& di (inhibited_groups < max_activation_inhibited_out_of_sync_groups) && maybe_majority_info.valid()) { - const auto* candidate = e->getNode(best->_nodeIndex); - if (!candidate->getBucketInfo().equalDocumentInfo(maybe_majority_info) && !candidate->active()) { + const auto & candidate = e->getNodeRef(best->entryIndex()); + if (!candidate.getBucketInfo().equalDocumentInfo(maybe_majority_info) && !candidate.active()) { ++inhibited_groups; continue; // Do _not_ add candidate as activation target since it's out of sync with the majority } diff --git a/storage/src/vespa/storage/distributor/activecopy.h b/storage/src/vespa/storage/distributor/activecopy.h index e54f4f27ca4..0322309ae8d 100644 --- a/storage/src/vespa/storage/distributor/activecopy.h +++ b/storage/src/vespa/storage/distributor/activecopy.h @@ -19,7 +19,7 @@ public: : _nodeIndex(Index::invalid()), _ideal(Index::invalid()), _doc_count(0), - _entryIndex(0), + _entryIndex(Index::invalid()), _ready(false), _active(false) { } @@ -38,7 +38,7 @@ public: static ActiveList calculate(const Node2Index & idealState, const lib::Distribution&, const BucketDatabase::Entry&, uint32_t max_activation_inhibited_out_of_sync_groups); uint16_t nodeIndex() const noexcept { return _nodeIndex; } - uint16_t entryIndex() const noexcept { return _entryIndex; } + Index entryIndex() const noexcept { return Index(_entryIndex); } private: friend ActiveStateOrder; bool valid_ideal() const noexcept { return _ideal < Index::invalid(); } diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp index 3b9594cf22f..17b1549ccc0 100644 --- a/storage/src/vespa/storage/distributor/statecheckers.cpp +++ b/storage/src/vespa/storage/distributor/statecheckers.cpp @@ -945,12 +945,13 @@ shouldSkipActivationDueToMaintenanceOrGatherOperationNodes(const ActiveList &act const StateChecker::Context &c, std::vector & operationNodes) { for (uint32_t i = 0; i < activeNodes.size(); ++i) { - const auto node_index = activeNodes[i].nodeIndex(); - const BucketCopy *cp(c.entry->getNode(node_index)); - if (!cp || cp->active()) { - continue; - } - if (!cp->ready()) { + const ActiveCopy & active = activeNodes[i]; + if ( ! active.entryIndex().valid()) continue; + const BucketCopy & cp(c.entry->getNodeRef(active.entryIndex())); + if (cp.active()) continue; + + const auto node_index = active.nodeIndex(); + if (!cp.ready()) { if (!c.op_ctx.node_supported_features_repo().node_supported_features(node_index).no_implicit_indexing_of_active_buckets) { // If copy is not ready, we don't want to activate it if a node // is set in maintenance. Doing so would imply that we want proton -- cgit v1.2.3