From 570390c9b3353fb9b9957895cadd63211ca6bb63 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 2 Mar 2023 15:40:52 +0100 Subject: Compute index.maxflushed based on concurrency --- .../vespa/model/content/ContentSearchCluster.java | 10 +++++++++ .../search/test/DocumentDatabaseTestCase.java | 24 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'config-model') diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java index 71726b50391..a0240d28a3c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java @@ -426,6 +426,16 @@ public class ContentSearchCluster extends TreeConfigProducer } builder.indexing.optimize(feedSequencerType); + setMaxFlushed(builder); + } + + private void setMaxFlushed(ProtonConfig.Builder builder) { + // maxflushed should be moved down to proton + double concurrency = builder.feeding.build().concurrency(); + if (concurrency > defaultFeedConcurrency) { + int maxFlushes = (int)Math.ceil(4 * concurrency); + builder.index.maxflushed(maxFlushes); + } } private boolean isGloballyDistributed(NewDocumentType docType) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentDatabaseTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentDatabaseTestCase.java index ee885cdf43e..1df297c2bfc 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentDatabaseTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentDatabaseTestCase.java @@ -87,7 +87,7 @@ public class DocumentDatabaseTestCase { verifyConcurrency(nameAndModes, xmlTuning, expectedConcurrency, null); } - private void verifyConcurrency(List nameAndModes, String xmlTuning, double expectedConcurrency, Double featureFlagConcurrency) { + private ProtonConfig getConfig(List nameAndModes, String xmlTuning, Double featureFlagConcurrency) { TestProperties properties = new TestProperties(); if (featureFlagConcurrency != null) { properties.setFeedConcurrency(featureFlagConcurrency); @@ -95,10 +95,30 @@ public class DocumentDatabaseTestCase { var tester = new SchemaTester(); VespaModel model = tester.createModel(nameAndModes, xmlTuning, new DeployState.Builder().properties(properties)); ContentSearchCluster contentSearchCluster = model.getContentClusters().get("test").getSearch(); - ProtonConfig proton = tester.getProtonConfig(contentSearchCluster); + return tester.getProtonConfig(contentSearchCluster); + } + + private void verifyConcurrency(List nameAndModes, String xmlTuning, double expectedConcurrency, Double featureFlagConcurrency) { + ProtonConfig proton = getConfig(nameAndModes, xmlTuning, featureFlagConcurrency); assertEquals(expectedConcurrency, proton.feeding().concurrency(), SMALL); } + private void verifyMaxflushedFollowsConcurrency(double concurrency, int maxFlushed) { + String feedTuning = " " + concurrency +"" + "\n"; + ProtonConfig proton = getConfig(List.of(DocType.create("a", "index")), feedTuning, null); + assertEquals(maxFlushed, proton.index().maxflushed()); + } + + @Test + public void verifyThatMaxFlushedFollowsConcurrency() { + verifyMaxflushedFollowsConcurrency(0.1, 2); + verifyMaxflushedFollowsConcurrency(0.50, 2); + verifyMaxflushedFollowsConcurrency(0.51, 3); + verifyMaxflushedFollowsConcurrency(0.75, 3); + verifyMaxflushedFollowsConcurrency(0.76, 4); + verifyMaxflushedFollowsConcurrency(1.0, 4); + } + private void verifyFeedNiceness(List nameAndModes, Double expectedNiceness, Double featureFlagNiceness) { TestProperties properties = new TestProperties(); if (featureFlagNiceness != null) { -- cgit v1.2.3