diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-10-29 15:10:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-29 15:10:34 +0100 |
commit | 8f58f2bd6aceba7442fb0c79734c09186e5bbeb6 (patch) | |
tree | 63fed8403c025634ac70c54919e410f38c4e3409 | |
parent | f9076902965b87a25827a41925edda9b9e728f77 (diff) | |
parent | c6c9a282b21f7a9d88cdb64a9e60d2cfc03aafe4 (diff) |
Merge pull request #29135 from vespa-engine/balder/move-computation-of-target-num-docs-to-backend
Balder/move computation of target num docs to backend
10 files changed, 95 insertions, 161 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java index 273e5580403..490d58d84b8 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java @@ -56,7 +56,7 @@ public class DomSearchTuningBuilder extends VespaDomBuilder.DomConfigProducerBui } else if (equals("flushstrategy", e)) { handleFlushStrategy(e, t.searchNode); } else if (equals("resizing", e)) { - handleResizing(deployLogger, e, t.searchNode); + deployLogger.logApplicationPackage(Level.WARNING, "searchnode.resizing is deprecated and ignored"); } else if (equals("index", e)) { handleIndex(deployLogger, e, t.searchNode); } else if (equals("attribute", e)) { @@ -164,18 +164,6 @@ public class DomSearchTuningBuilder extends VespaDomBuilder.DomConfigProducerBui } } - private void handleResizing(DeployLogger deployLogger, Element spec, Tuning.SearchNode sn) { - sn.resizing = new Tuning.SearchNode.Resizing(); - for (Element e : XML.getChildren(spec)) { - if (equals("initialdocumentcount", e)) { - deployLogger.logApplicationPackage(Level.WARNING, "resizing.initialdocumentcount is deprecated."); - sn.resizing.initialDocumentCount = asInt(e); - } else if (equals("amortize-count", e)) { - deployLogger.logApplicationPackage(Level.WARNING, "resizing.amortize-count is deprecated and ignored"); - } - } - } - private void handleIndex(DeployLogger deployLogger, Element spec, Tuning.SearchNode sn) { sn.index = new Tuning.SearchNode.Index(); for (Element e : XML.getChildren(spec)) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java b/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java index 2beec421faa..2616dd8a93c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/NodeResourcesTuning.java @@ -23,21 +23,16 @@ public class NodeResourcesTuning implements ProtonConfig.Producer { private final static double TLS_SIZE_FRACTION = 0.02; final static long MB = 1024 * 1024; public final static long GB = MB * 1024; - // This is an approximate number based on observation of a node using 33G memory with 765M docs - private final static long MEMORY_COST_PER_DOCUMENT_DB_ONLY = 46L; private final NodeResources resources; private final int threadsPerSearch; private final double fractionOfMemoryReserved; - private final Redundancy redundancy; public NodeResourcesTuning(NodeResources resources, int threadsPerSearch, - double fractionOfMemoryReserved, - Redundancy redundancy) { + double fractionOfMemoryReserved) { this.resources = resources; this.threadsPerSearch = threadsPerSearch; this.fractionOfMemoryReserved = fractionOfMemoryReserved; - this.redundancy = redundancy; } @Override @@ -52,18 +47,6 @@ public class NodeResourcesTuning implements ProtonConfig.Producer { tuneSummaryReadIo(builder.summary.read); tuneSummaryCache(builder.summary.cache); tuneSearchReadIo(builder.search.mmap); - for (ProtonConfig.Documentdb.Builder dbb : builder.documentdb) { - getConfig(dbb); - } - } - - private void getConfig(ProtonConfig.Documentdb.Builder builder) { - // TODO => Move this to backend to enable ignoring this setting. - ProtonConfig.Documentdb dbCfg = builder.build(); - if (dbCfg.mode() != ProtonConfig.Documentdb.Mode.Enum.INDEX) { - long numDocs = (long)usableMemoryGb() * GB / MEMORY_COST_PER_DOCUMENT_DB_ONLY; - builder.allocation.initialnumdocs(numDocs/redundancy.readyCopies()); - } } private void tuneSummaryCache(ProtonConfig.Summary.Cache.Builder builder) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java index 83c1778b95e..c0f22da2982 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java @@ -284,7 +284,7 @@ public class SearchNode extends AbstractService implements if (nodeResources.isPresent()) { var nodeResourcesTuning = new NodeResourcesTuning(nodeResources.get(), tuning.map(Tuning::threadsPerSearch).orElse(1), - fractionOfMemoryReserved, redundancyProvider.redundancy()); + fractionOfMemoryReserved); nodeResourcesTuning.getConfig(builder); tuning.ifPresent(t -> t.getConfig(builder)); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java b/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java index 9621ddd1374..90a2bd7c734 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java @@ -119,21 +119,6 @@ public class Tuning extends AnyConfigProducer implements ProtonConfig.Producer { } } - public static class Resizing implements ProtonConfig.Producer { - // TODO GC as soon as resource computation is moved to backend. - public Integer initialDocumentCount = null; - - @Override - public void getConfig(ProtonConfig.Builder builder) { - if (initialDocumentCount!=null) { - for (ProtonConfig.Documentdb.Builder db : builder.documentdb) { - db.allocation.initialnumdocs(initialDocumentCount); - } - } - } - - } - public static class Index implements ProtonConfig.Producer { public static class Io implements ProtonConfig.Producer { public IoType search = null; @@ -347,7 +332,6 @@ public class Tuning extends AnyConfigProducer implements ProtonConfig.Producer { public RequestThreads threads = null; public LidSpace lidSpace = null; public FlushStrategy strategy = null; - public Resizing resizing = null; public Index index = null; public Summary summary = null; public Initialize initialize = null; @@ -359,7 +343,6 @@ public class Tuning extends AnyConfigProducer implements ProtonConfig.Producer { if (threads != null) threads.getConfig(builder); if (lidSpace != null) lidSpace.getConfig(builder); if (strategy != null) strategy.getConfig(builder); - if (resizing != null) resizing.getConfig(builder); if (index != null) index.getConfig(builder); if (summary != null) summary.getConfig(builder); if (initialize != null) initialize.getConfig(builder); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java index 963fce0c666..764e31fe13a 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java @@ -103,15 +103,6 @@ public class DomSchemaTuningBuilderTest extends DomBuilderTest { } @Test - void requireThatWeCanParseResizingTag() { - Tuning t = createTuning(parseXml("<resizing>", - "<initialdocumentcount>128</initialdocumentcount>", - "<amortize-count>13</amortize-count>", - "</resizing>")); - assertEquals(128, t.searchNode.resizing.initialDocumentCount.intValue()); - } - - @Test void requireThatWeCanParseIndexTag() { Tuning t = createTuning(parseXml("<index>", "<io>", "<search>mmap</search>", diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java index 1f143fd2d82..fbc4f6768a2 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/NodeResourcesTuningTest.java @@ -1,16 +1,12 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.search; -import com.yahoo.collections.Pair; import com.yahoo.config.provision.Flavor; import com.yahoo.config.provisioning.FlavorsConfig; import com.yahoo.vespa.config.search.core.ProtonConfig; import com.yahoo.vespa.model.container.ApplicationContainerCluster; -import com.yahoo.vespa.model.content.Redundancy; import org.junit.jupiter.api.Test; -import java.util.List; - import static com.yahoo.vespa.model.Host.memoryOverheadGb; import static org.junit.jupiter.api.Assertions.assertEquals; import static com.yahoo.vespa.model.search.NodeResourcesTuning.MB; @@ -41,35 +37,6 @@ public class NodeResourcesTuningTest { assertEquals(0.7, memoryOverheadGb, delta); } - private ProtonConfig getProtonMemoryConfig(List<Pair<String, String>> sdAndMode, double gb, Redundancy redundancy) { - ProtonConfig.Builder builder = new ProtonConfig.Builder(); - for (Pair<String, String> sdMode : sdAndMode) { - builder.documentdb.add(new ProtonConfig.Documentdb.Builder() - .inputdoctypename(sdMode.getFirst()) - .configid("some/config/id/" + sdMode.getFirst()) - .mode(ProtonConfig.Documentdb.Mode.Enum.valueOf(sdMode.getSecond()))); - } - return configFromMemorySetting(gb, builder, redundancy); - } - - private void verify_that_initial_numdocs_is_dependent_of_mode(int readyCopies) { - ProtonConfig cfg = getProtonMemoryConfig(List.of(new Pair<>("a", "INDEX"), new Pair<>("b", "STREAMING"), new Pair<>("c", "STORE_ONLY")), - 24 + memoryOverheadGb, new Redundancy(readyCopies+1,readyCopies+1, readyCopies,1, readyCopies)); - assertEquals(3, cfg.documentdb().size()); - assertEquals(1024, cfg.documentdb(0).allocation().initialnumdocs()); - assertEquals("a", cfg.documentdb(0).inputdoctypename()); - assertEquals(24 * GB / (46 * readyCopies), cfg.documentdb(1).allocation().initialnumdocs()); - assertEquals("b", cfg.documentdb(1).inputdoctypename()); - assertEquals(24 * GB / (46 * readyCopies), cfg.documentdb(2).allocation().initialnumdocs()); - assertEquals("c", cfg.documentdb(2).inputdoctypename()); - } - - @Test - void require_that_initial_numdocs_is_dependent_of_mode_and_searchablecopies() { - verify_that_initial_numdocs_is_dependent_of_mode(1); - verify_that_initial_numdocs_is_dependent_of_mode(2); - } - @Test void require_that_hwinfo_cpu_cores_is_set() { ProtonConfig cfg = configFromNumCoresSetting(24); @@ -227,9 +194,9 @@ public class NodeResourcesTuningTest { return getConfig(new FlavorsConfig.Flavor.Builder().minMainMemoryAvailableGb(memoryGb), fractionOfMemoryReserved); } - private static ProtonConfig configFromMemorySetting(double memoryGb, ProtonConfig.Builder builder, Redundancy redundancy) { + private static ProtonConfig configFromMemorySetting(double memoryGb, ProtonConfig.Builder builder) { return getConfig(new FlavorsConfig.Flavor.Builder() - .minMainMemoryAvailableGb(memoryGb), builder, redundancy); + .minMainMemoryAvailableGb(memoryGb), builder); } private static ProtonConfig configFromNumCoresSetting(double numCores) { @@ -255,11 +222,7 @@ public class NodeResourcesTuningTest { } private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder) { - return getConfig(flavorBuilder, protonBuilder, new Redundancy(1,1,1,1,1)); - } - private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, - Redundancy redundancy) { - return getConfig(flavorBuilder, protonBuilder,1, redundancy); + return getConfig(flavorBuilder, protonBuilder,1); } private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, double fractionOfMemoryReserved) { return getConfig(flavorBuilder, protonBuilder, 1, fractionOfMemoryReserved); @@ -267,24 +230,14 @@ public class NodeResourcesTuningTest { private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, int numThreadsPerSearch) { - return getConfig(flavorBuilder, protonBuilder, numThreadsPerSearch, new Redundancy(1,1,1,1,1)); - } - - private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, - int numThreadsPerSearch, Redundancy redundancy) { - return getConfig(flavorBuilder, protonBuilder, numThreadsPerSearch, 0, redundancy); + return getConfig(flavorBuilder, protonBuilder, numThreadsPerSearch, 0); } private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, int numThreadsPerSearch, double fractionOfMemoryReserved) { - return getConfig(flavorBuilder, protonBuilder, numThreadsPerSearch, fractionOfMemoryReserved, - new Redundancy(1,1,1,1,1)); - } - private static ProtonConfig getConfig(FlavorsConfig.Flavor.Builder flavorBuilder, ProtonConfig.Builder protonBuilder, - int numThreadsPerSearch, double fractionOfMemoryReserved, Redundancy redundancy) { flavorBuilder.name("my_flavor"); NodeResourcesTuning tuning = new NodeResourcesTuning(new Flavor(new FlavorsConfig.Flavor(flavorBuilder)).resources(), - numThreadsPerSearch, fractionOfMemoryReserved, redundancy); + numThreadsPerSearch, fractionOfMemoryReserved); tuning.getConfig(protonBuilder); return new ProtonConfig(protonBuilder); } 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 685610544fe..5b501bad876 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 @@ -173,16 +173,6 @@ public class DocumentDatabaseTestCase { "", List.of(DEFAULT, DEFAULT)); } - @Test - void requireThatMixedModeInitialDocumentCountIsReflected() { - final long INITIAL = 1000000000L; - String feedTuning = "<resizing>" + - " <initialdocumentcount>1000000000</initialdocumentcount>" + - "</resizing>\n"; - verifyInitialDocumentCount(List.of(DocType.create("a", "index"), DocType.create("b", "streaming")), - feedTuning, List.of(INITIAL, INITIAL)); - } - private void assertDocTypeConfig(VespaModel model, String configId, String indexField, String attributeField) { IndexschemaConfig icfg = model.getConfig(IndexschemaConfig.class, configId); assertEquals(1, icfg.indexfield().size()); diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index 9dd5ecacd91..ae81a235b0e 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -21,11 +21,9 @@ #include <vespa/searchcore/proton/common/subdbtype.h> #include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchsummary/config/config-juniperrc.h> -#include <vespa/document/config/documenttypes_config_fwd.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/fileacquirer/config-filedistributorrpc.h> #include <vespa/vespalib/util/varholder.h> -#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/testkit/testapp.h> #include <map> #include <thread> @@ -73,7 +71,7 @@ struct ConfigTestFixture { std::shared_ptr<IConfigContext> context; int idcounter; - ConfigTestFixture(const std::string & id) + explicit ConfigTestFixture(const std::string & id) : configId(id), protonBuilder(), documenttypesBuilder(), @@ -93,7 +91,15 @@ struct ConfigTestFixture { ~ConfigTestFixture() = default; - DoctypeFixture *addDocType(const std::string &name, bool isGlobal = false) { + DoctypeFixture *addDocType(const std::string &name) { + return addDocType(name, ProtonConfig::Documentdb::Mode::INDEX); + } + + DoctypeFixture *addDocType(const std::string &name, ProtonConfig::Documentdb::Mode mode) { + return addDocType(name, mode, false); + } + + DoctypeFixture *addDocType(const std::string &name, ProtonConfig::Documentdb::Mode mode, bool isGlobal) { DocumenttypesConfigBuilder::Documenttype dt; dt.bodystruct = -1270491200; dt.headerstruct = 306916075; @@ -106,6 +112,7 @@ struct ConfigTestFixture { db.inputdoctypename = name; db.configid = configId + "/" + name; db.global = isGlobal; + db.mode = mode; protonBuilder.documentdb.push_back(db); DoctypeFixture::UP fixture = std::make_unique<DoctypeFixture>(); @@ -118,7 +125,7 @@ struct ConfigTestFixture { set.addBuilder(db.configid, &fixture->summaryBuilder); set.addBuilder(db.configid, &fixture->juniperrcBuilder); set.addBuilder(db.configid, &fixture->importedFieldsBuilder); - return dbConfig.emplace(std::make_pair(name, std::move(fixture))).first->second.get(); + return dbConfig.emplace(name, std::move(fixture)).first->second.get(); } void removeDocType(const std::string & name) @@ -142,20 +149,20 @@ struct ConfigTestFixture { } } - bool configEqual(const std::string & name, DocumentDBConfig::SP dbc) { + bool configEqual(const std::string & name, const DocumentDBConfig & dbc) { auto itr = dbConfig.find(name); ASSERT_TRUE(itr != dbConfig.end()); const auto *fixture = itr->second.get(); - return (fixture->attributesBuilder == dbc->getAttributesConfig() && - fixture->rankProfilesBuilder == dbc->getRankProfilesConfig() && - fixture->indexschemaBuilder == dbc->getIndexschemaConfig() && - fixture->summaryBuilder == dbc->getSummaryConfig() && - fixture->juniperrcBuilder == dbc->getJuniperrcConfig()); + return (fixture->attributesBuilder == dbc.getAttributesConfig() && + fixture->rankProfilesBuilder == dbc.getRankProfilesConfig() && + fixture->indexschemaBuilder == dbc.getIndexschemaConfig() && + fixture->summaryBuilder == dbc.getSummaryConfig() && + fixture->juniperrcBuilder == dbc.getJuniperrcConfig()); } - bool configEqual(BootstrapConfig::SP bootstrapConfig) { - return (protonBuilder == bootstrapConfig->getProtonConfig() && - documenttypesBuilder == bootstrapConfig->getDocumenttypesConfig()); + bool configEqual(const BootstrapConfig & bootstrapConfig) const { + return (protonBuilder == bootstrapConfig.getProtonConfig() && + documenttypesBuilder == bootstrapConfig.getDocumenttypesConfig()); } BootstrapConfig::SP getBootstrapConfig(int64_t generation, const HwInfo & hwInfo) const { @@ -180,7 +187,7 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer ProtonConfigOwner() : _configured(false), _config() { } ~ProtonConfigOwner() override; - bool waitUntilConfigured(vespalib::duration timeout) { + bool waitUntilConfigured(vespalib::duration timeout) const { vespalib::Timer timer; while (timer.elapsed() < timeout) { if (getConfigured()) @@ -189,7 +196,7 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer } return getConfigured(); } - virtual void reconfigure(std::shared_ptr<ProtonConfigSnapshot> cfg) override { + void reconfigure(std::shared_ptr<ProtonConfigSnapshot> cfg) override { std::lock_guard<std::mutex> guard(_mutex); _config.set(cfg); _configured = true; @@ -198,11 +205,11 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer std::lock_guard<std::mutex> guard(_mutex); return _configured; } - BootstrapConfig::SP getBootstrapConfig() { + BootstrapConfig::SP getBootstrapConfig() const { auto snapshot = _config.get(); return snapshot->getBootstrapConfig(); } - DocumentDBConfig::SP getDocumentDBConfig(const vespalib::string &name) + DocumentDBConfig::SP getDocumentDBConfig(const vespalib::string &name) const { auto snapshot = _config.get(); auto &dbcs = snapshot->getDocumentDBConfigs(); @@ -210,7 +217,7 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer if (dbitr != dbcs.end()) { return dbitr->second; } else { - return DocumentDBConfig::SP(); + return {}; } } }; @@ -232,18 +239,18 @@ TEST_FFF("require that bootstrap config manager updates config", ConfigTestFixtu BootstrapConfigManager(f1.configId), ConfigRetriever(f2.createConfigKeySet(), f1.context)) { f2.update(f3.getBootstrapConfigs()); - ASSERT_TRUE(f1.configEqual(f2.getConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getConfig())); f1.protonBuilder.rpcport = 9010; - ASSERT_FALSE(f1.configEqual(f2.getConfig())); + ASSERT_FALSE(f1.configEqual(*f2.getConfig())); f1.reload(); f2.update(f3.getBootstrapConfigs()); - ASSERT_TRUE(f1.configEqual(f2.getConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getConfig())); f1.addDocType("foobar"); - ASSERT_FALSE(f1.configEqual(f2.getConfig())); + ASSERT_FALSE(f1.configEqual(*f2.getConfig())); f1.reload(); f2.update(f3.getBootstrapConfigs()); - ASSERT_TRUE(f1.configEqual(f2.getConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getConfig())); } DocumentDBConfig::SP @@ -267,7 +274,7 @@ TEST_FF("require that documentdb config manager subscribes for config", f1.addDocType("typea"); const ConfigKeySet keySet(f2.createConfigKeySet()); ASSERT_EQUAL(9u, keySet.size()); - ASSERT_TRUE(f1.configEqual("typea", getDocumentDBConfig(f1, f2))); + ASSERT_TRUE(f1.configEqual("typea", *getDocumentDBConfig(f1, f2))); } TEST_FF("require that documentdb config manager builds schema with imported attribute fields" @@ -305,12 +312,12 @@ TEST_FFF("require that proton config fetcher follows changes to bootstrap", ProtonConfigFetcher(f1.transport.transport(), ConfigUri(f1.configId, f1.context), f2, 60s)) { f3.start(); ASSERT_TRUE(f2._configured); - ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); f2._configured = false; f1.protonBuilder.rpcport = 9010; f1.reload(); ASSERT_TRUE(f2.waitUntilConfigured(120s)); - ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); f3.close(); } @@ -324,13 +331,13 @@ TEST_FFF("require that proton config fetcher follows changes to doctypes", f1.addDocType("typea"); f1.reload(); ASSERT_TRUE(f2.waitUntilConfigured(60s)); - ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); f2._configured = false; f1.removeDocType("typea"); f1.reload(); ASSERT_TRUE(f2.waitUntilConfigured(60s)); - ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); f3.close(); } @@ -346,9 +353,9 @@ TEST_FFF("require that proton config fetcher reconfigures dbowners", f1.addDocType("typea"); f1.reload(); ASSERT_TRUE(f2.waitUntilConfigured(60s)); - ASSERT_TRUE(f1.configEqual(f2.getBootstrapConfig())); + ASSERT_TRUE(f1.configEqual(*f2.getBootstrapConfig())); ASSERT_TRUE(static_cast<bool>(f2.getDocumentDBConfig("typea"))); - ASSERT_TRUE(f1.configEqual("typea", f2.getDocumentDBConfig("typea"))); + ASSERT_TRUE(f1.configEqual("typea", *f2.getDocumentDBConfig("typea"))); // Remove and verify that config for db is no longer provided f2._configured = false; @@ -363,11 +370,45 @@ TEST_FF("require that lid space compaction is disabled for globally distributed ConfigTestFixture("search"), DocumentDBConfigManager(f1.configId + "/global", "global")) { - f1.addDocType("global", true); + f1.addDocType("global", ProtonConfig::Documentdb::Mode::INDEX, true); auto config = getDocumentDBConfig(f1, f2); EXPECT_TRUE(config->getMaintenanceConfigSP()->getLidSpaceCompactionConfig().isDisabled()); } +HwInfo +createHwInfoWithMemory(uint64_t mem) { + return {HwInfo::Disk(1, false, false), HwInfo::Memory(mem), HwInfo::Cpu(1)}; +} + +TEST_FF("require that target numdocs is fixed 1k for indexed mode", + ConfigTestFixture("search"), + DocumentDBConfigManager(f1.configId + "/test", "test")) +{ + f1.addDocType("test", ProtonConfig::Documentdb::Mode::INDEX, true); + for (uint64_t memory : {1_Gi, 10_Gi}) { + auto config = getDocumentDBConfig(f1, f2, createHwInfoWithMemory(memory)); + AllocStrategy strategy = config->get_alloc_config().make_alloc_strategy(SubDbType::READY); + EXPECT_EQUAL(1024u, strategy.get_grow_strategy().getMinimumCapacity()); + } +} + +TEST_FF("require that target numdocs follows memory for streaming mode", + ConfigTestFixture("search"), + DocumentDBConfigManager(f1.configId + "/test", "test")) +{ + f1.addDocType("test", ProtonConfig::Documentdb::Mode::STREAMING, true); + { + auto config = getDocumentDBConfig(f1, f2, createHwInfoWithMemory(1_Gi)); + AllocStrategy strategy = config->get_alloc_config().make_alloc_strategy(SubDbType::READY); + EXPECT_EQUAL(23342213u, strategy.get_grow_strategy().getMinimumCapacity()); + } + { + auto config = getDocumentDBConfig(f1, f2, createHwInfoWithMemory(10_Gi)); + AllocStrategy strategy = config->get_alloc_config().make_alloc_strategy(SubDbType::READY); + EXPECT_EQUAL(233422135u, strategy.get_grow_strategy().getMinimumCapacity()); + } +} + TEST_FF("require that prune removed documents interval can be set based on age", ConfigTestFixture("test"), DocumentDBConfigManager(f1.configId + "/test", "test")) @@ -383,7 +424,7 @@ TEST_FF("require that docstore config computes cachesize automatically if unset" ConfigTestFixture("test"), DocumentDBConfigManager(f1.configId + "/test", "test")) { - HwInfo hwInfo(HwInfo::Disk(1, false, false), HwInfo::Memory(1000000), HwInfo::Cpu(1)); + HwInfo hwInfo = createHwInfoWithMemory(1000000); f1.addDocType("test"); f1.protonBuilder.summary.cache.maxbytes = 2000; auto config = getDocumentDBConfig(f1, f2, hwInfo); @@ -400,7 +441,7 @@ TEST_FF("require that docstore config computes cachesize automatically if unset" GrowStrategy growStrategy(uint32_t initial) { - return GrowStrategy(initial, 0.1, 1, initial, 0.15); + return {initial, 0.1, 1, initial, 0.15}; } TEST_FF("require that allocation config is propagated", ConfigTestFixture("test"), diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index bd23ce66977..c6cba6fab3d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -11,7 +11,6 @@ #include <vespa/config-ranking-constants.h> #include <vespa/config-ranking-expressions.h> #include <vespa/config-summary.h> -#include <vespa/config/common/exceptions.h> #include <vespa/config/common/configcontext.h> #include <vespa/config/retriever/configretriever.h> #include <vespa/config/helper/legacy.h> @@ -53,7 +52,7 @@ using vespalib::datastore::CompactionStrategy; namespace proton { -const ConfigKeySet +ConfigKeySet DocumentDBConfigManager::createConfigKeySet() const { ConfigKeySet set; @@ -223,13 +222,19 @@ find_document_db_config_entry(const ProtonConfig::DocumentdbVector& document_dbs return default_document_db_config_entry; } -const AllocConfig -build_alloc_config(const ProtonConfig& proton_config, const vespalib::string& doc_type_name) +AllocConfig +build_alloc_config(const HwInfo & hwInfo, const ProtonConfig& proton_config, const vespalib::string& doc_type_name) { + // This is an approximate number based on observation of a node using 33G memory with 765M docs + constexpr uint64_t MIN_MEMORY_COST_PER_DOCUMENT = 46; + auto& document_db_config_entry = find_document_db_config_entry(proton_config.documentdb, doc_type_name); auto& alloc_config = document_db_config_entry.allocation; + uint32_t target_numdocs = (document_db_config_entry.mode != ProtonConfig::Documentdb::Mode::INDEX) + ? (hwInfo.memory().sizeBytes() / (MIN_MEMORY_COST_PER_DOCUMENT * proton_config.distribution.searchablecopies)) + : alloc_config.initialnumdocs; auto& distribution_config = proton_config.distribution; - search::GrowStrategy grow_strategy(alloc_config.initialnumdocs, alloc_config.growfactor, alloc_config.growbias, alloc_config.initialnumdocs, alloc_config.multivaluegrowfactor); + search::GrowStrategy grow_strategy(target_numdocs, alloc_config.growfactor, alloc_config.growbias, target_numdocs, alloc_config.multivaluegrowfactor); CompactionStrategy compaction_strategy(alloc_config.maxDeadBytesRatio, alloc_config.maxDeadAddressSpaceRatio, alloc_config.maxCompactBuffers, alloc_config.activeBuffersRatio); return AllocConfig(AllocStrategy(grow_strategy, compaction_strategy, alloc_config.amortizecount), distribution_config.redundancy, distribution_config.searchablecopies); @@ -341,7 +346,7 @@ DocumentDBConfigManager::update(FNET_Transport & transport, const ConfigSnapshot newMaintenanceConfig, storeConfig, ThreadingServiceConfig::make(_bootstrapConfig->getProtonConfig()), - build_alloc_config(_bootstrapConfig->getProtonConfig(), _docTypeName), + build_alloc_config(_bootstrapConfig->getHwInfo(), _bootstrapConfig->getProtonConfig(), _docTypeName), _configId, _docTypeName); assert(newSnapshot->valid()); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h index 59f70a3993b..07e05dc1585 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h @@ -44,7 +44,7 @@ public: DocumentDBConfig::SP getConfig() const; void forwardConfig(const BootstrapConfigSP & config); - const config::ConfigKeySet createConfigKeySet() const; + config::ConfigKeySet createConfigKeySet() const; const vespalib::string & getConfigId() const { return _configId; } }; |