diff options
Diffstat (limited to 'config-model')
4 files changed, 35 insertions, 13 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index eb628db6975..3298b627b19 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -12,6 +12,7 @@ import com.yahoo.config.provision.AthenzDomain; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.Zone; +import com.yahoo.vespa.model.container.ApplicationContainerCluster; import java.net.URI; import java.security.cert.X509Certificate; @@ -76,6 +77,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea private int rpc_num_targets = 1; private int rpc_events_before_wakeup = 1; private int mbus_network_threads = 1; + private int heapSizePercentage = ApplicationContainerCluster.defaultHeapSizePercentageOfTotalNodeMemory; private Architecture adminClusterNodeResourcesArchitecture = Architecture.getDefault(); private boolean useRestrictedDataPlaneBindings = false; @@ -127,6 +129,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea @Override public int mbusCppRpcNumTargets() { return mbus_cpp_num_targets; } @Override public int mbusCppEventsBeforeWakeup() { return mbus_cpp_events_before_wakeup; } @Override public int rpcNumTargets() { return rpc_num_targets; } + @Override public int heapSizePercentage() { return heapSizePercentage; } @Override public int rpcEventsBeforeWakeup() { return rpc_events_before_wakeup; } @Override public String queryDispatchPolicy() { return queryDispatchPolicy; } @Override public boolean useTwoPhaseDocumentGc() { return useTwoPhaseDocumentGc; } @@ -166,6 +169,11 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea return this; } + public TestProperties setHeapSizePercentage(int percentage) { + this.heapSizePercentage = percentage; + return this; + } + public TestProperties setAsyncMessageHandlingOnSchedule(boolean value) { useAsyncMessageHandlingOnSchedule = value; return this; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java index ea135ba9749..5703de4cb18 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java @@ -76,7 +76,7 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat private static final BindingPattern PROMETHEUS_V1_HANDLER_BINDING_1 = SystemBindingPattern.fromHttpPath(PrometheusV1Handler.V1_PATH); private static final BindingPattern PROMETHEUS_V1_HANDLER_BINDING_2 = SystemBindingPattern.fromHttpPath(PrometheusV1Handler.V1_PATH + "/*"); - public static final int heapSizePercentageOfTotalNodeMemory = 70; + public static final int defaultHeapSizePercentageOfTotalNodeMemory = 70; public static final int heapSizePercentageOfTotalNodeMemoryWhenCombinedCluster = 18; private final Set<FileReference> applicationBundles = new LinkedHashSet<>(); @@ -91,6 +91,7 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat private boolean messageBusEnabled = true; private final int transport_events_before_wakeup; private final int transport_connections_per_target; + private final int heapSizePercentageOfTotalNodeMemory; private Integer memoryPercentage = null; @@ -118,6 +119,9 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat addTestrunnerComponentsIfTester(deployState); transport_connections_per_target = deployState.featureFlags().mbusJavaRpcNumTargets(); transport_events_before_wakeup = deployState.featureFlags().mbusJavaEventsBeforeWakeup(); + heapSizePercentageOfTotalNodeMemory = deployState.featureFlags().heapSizePercentage() > 0 + ? Math.min(99, deployState.featureFlags().heapSizePercentage()) + : defaultHeapSizePercentageOfTotalNodeMemory; } @Override @@ -169,8 +173,7 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat this.modelEvaluation = modelEvaluation; } - public void setMemoryPercentage(Integer memoryPercentage) { this.memoryPercentage = memoryPercentage; - } + public void setMemoryPercentage(Integer memoryPercentage) { this.memoryPercentage = memoryPercentage; } @Override public Optional<Integer> getMemoryPercentage() { diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java index 5f57c399cfd..3dfb04a90ad 100644 --- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java @@ -224,7 +224,7 @@ public class ModelProvisioningTest { assertEquals(2, model.getContentClusters().get("content1").getRootGroup().getNodes().size(), "Nodes in content1"); assertEquals(1, model.getContainerClusters().get("container1").getContainers().size(), "Nodes in container1"); assertEquals(2, model.getContentClusters().get("content").getRootGroup().getNodes().size(), "Nodes in cluster without ID"); - assertEquals(70, physicalMemoryPercentage(model.getContainerClusters().get("container1")), "Heap size for container"); + assertEquals(ApplicationContainerCluster.defaultHeapSizePercentageOfTotalNodeMemory, physicalMemoryPercentage(model.getContainerClusters().get("container1")), "Heap size for container"); assertProvisioned(2, ClusterSpec.Id.from("content1"), ClusterSpec.Type.content, model); assertProvisioned(1, ClusterSpec.Id.from("container1"), ClusterSpec.Type.container, model); assertProvisioned(2, ClusterSpec.Id.from("content"), ClusterSpec.Type.content, model); @@ -345,7 +345,7 @@ public class ModelProvisioningTest { VespaModel model = tester.createModel(xmlWithNodes, true); assertEquals(2, model.getContentClusters().get("content1").getRootGroup().getNodes().size(), "Nodes in content1"); assertEquals(2, model.getContainerClusters().get("container1").getContainers().size(), "Nodes in container1"); - assertEquals(70, physicalMemoryPercentage(model.getContainerClusters().get("container1")), "Heap size is normal"); + assertEquals(ApplicationContainerCluster.defaultHeapSizePercentageOfTotalNodeMemory, physicalMemoryPercentage(model.getContainerClusters().get("container1")), "Heap size is normal"); assertEquals((long) ((3 - reservedMemoryGb) * (Math.pow(1024, 3))), protonMemorySize(model.getContentClusters().get("content1")), "Memory for proton is normal"); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java index da70daa2b4d..e258790cd42 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java @@ -113,11 +113,11 @@ public class ContainerClusterTest { assertEquals("cd", config.system()); } - private void verifyHeapSizeAsPercentageOfPhysicalMemory(boolean isHosted, + private void verifyHeapSizeAsPercentageOfPhysicalMemory(MockRoot root, boolean isCombinedCluster, Integer explicitMemoryPercentage, int expectedMemoryPercentage) { - ApplicationContainerCluster cluster = newClusterWithSearch(createRoot(isHosted), isCombinedCluster, explicitMemoryPercentage); + ApplicationContainerCluster cluster = newClusterWithSearch(root, isCombinedCluster, explicitMemoryPercentage); QrStartConfig.Builder qsB = new QrStartConfig.Builder(); cluster.getConfig(qsB); QrStartConfig qsC= new QrStartConfig(qsB); @@ -127,16 +127,20 @@ public class ContainerClusterTest { @Test void requireThatHeapSizeAsPercentageOfPhysicalMemoryForHostedAndNot() { + int heapSizeInFlag = 89; boolean hosted = true; boolean combined = true; // a cluster running on content nodes (only relevant with hosted) - verifyHeapSizeAsPercentageOfPhysicalMemory( hosted, !combined, null, 70); - verifyHeapSizeAsPercentageOfPhysicalMemory( hosted, combined, null, 18); - verifyHeapSizeAsPercentageOfPhysicalMemory(!hosted, !combined, null, 0); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(hosted), !combined, null, ApplicationContainerCluster.defaultHeapSizePercentageOfTotalNodeMemory); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(hosted, heapSizeInFlag), !combined, null, heapSizeInFlag); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(hosted), combined, null, 18); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(hosted, heapSizeInFlag), combined, null, 18); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(!hosted), !combined, null, 0); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(!hosted, heapSizeInFlag), !combined, null, 0); // Explicit value overrides all defaults - verifyHeapSizeAsPercentageOfPhysicalMemory( hosted, !combined, 67, 67); - verifyHeapSizeAsPercentageOfPhysicalMemory( hosted, combined, 68, 68); - verifyHeapSizeAsPercentageOfPhysicalMemory(!hosted, !combined, 69, 69); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(hosted, heapSizeInFlag), !combined, 67, 67); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(hosted, heapSizeInFlag), combined, 68, 68); + verifyHeapSizeAsPercentageOfPhysicalMemory(createRoot(!hosted, heapSizeInFlag), !combined, 69, 69); } private void verifyJvmArgs(boolean isHosted, boolean hasDocproc, String expectedArgs, String jvmArgs) { @@ -502,6 +506,13 @@ public class ContainerClusterTest { DeployState state = new DeployState.Builder().properties(new TestProperties().setHostedVespa(isHosted)).build(); return createRoot(state); } + private static MockRoot createRoot(boolean isHosted, int heapSizePercentage) { + DeployState state = new DeployState.Builder().properties( + new TestProperties() + .setHostedVespa(isHosted) + .setHeapSizePercentage(heapSizePercentage)).build(); + return createRoot(state); + } private static MockRoot createRoot(DeployState deployState) { return new MockRoot("foo", deployState); |