summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-10 16:56:19 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-08-11 09:27:59 +0000
commitd18ee22daeab01118d8ec4c72bbcfa105f656b67 (patch)
tree38df5d43e037f25c40deaece20c45b46e0f01d18 /vdslib
parent4e19101d1019bc9c44ae077669e4526165387249 (diff)
When splitting a large number of nodes into their leaf groups you end up with many vectors with only a single node in them.
Then it is more efficient to use a small_vector that keeps the 4 first entries within. Reduces # allocations and avoids indirection.
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/tests/distribution/distributiontest.cpp4
-rw-r--r--vdslib/src/vespa/vdslib/distribution/distribution.h4
2 files changed, 6 insertions, 2 deletions
diff --git a/vdslib/src/tests/distribution/distributiontest.cpp b/vdslib/src/tests/distribution/distributiontest.cpp
index 33a6d47b719..ec7c05fa7a2 100644
--- a/vdslib/src/tests/distribution/distributiontest.cpp
+++ b/vdslib/src/tests/distribution/distributiontest.cpp
@@ -1031,4 +1031,8 @@ TEST(DistributionTest, DISABLED_benchmark_ideal_state_for_many_groups) {
fprintf(stderr, "%.10f seconds\n", min_time);
}
+TEST(DistributionTest, control_size_of_IndexList) {
+ EXPECT_EQ(24u, sizeof(Distribution::IndexList));
+}
+
}
diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.h b/vdslib/src/vespa/vdslib/distribution/distribution.h
index b39afb17e15..8cf93b01630 100644
--- a/vdslib/src/vespa/vdslib/distribution/distribution.h
+++ b/vdslib/src/vespa/vdslib/distribution/distribution.h
@@ -12,7 +12,7 @@
#include <vespa/document/bucket/bucketid.h>
#include <vespa/vdslib/state/nodetype.h>
#include <vespa/vespalib/util/exception.h>
-#include <vespa/vespalib/util/arrayref.h>
+#include <vespa/vespalib/util/small_vector.h>
namespace vespa::config::content::internal {
class InternalStorDistributionType;
@@ -148,7 +148,7 @@ public:
* Utility function used by distributor to split copies into groups to
* handle active per group feature.
*/
- using IndexList = std::vector<uint16_t>;
+ using IndexList = vespalib::SmallVector<uint16_t, 4>;
std::vector<IndexList> splitNodesIntoLeafGroups(vespalib::ConstArrayRef<uint16_t> nodes) const;
static bool allDistributorsDown(const Group&, const ClusterState&);