summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2020-09-01 11:55:27 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2020-09-03 15:57:27 +0200
commit20a2be2b64e591680305d322a14f56e3d2d06d91 (patch)
tree08cd583f3e534555f21f81ae6b94445d82777f38
parentdea4b4b9ce2aaaadfdca6b8f933967f4b359da25 (diff)
Change feature flag to control both core and max pool size
Change default multiplier from 1 to 4. Hardcode core pool size to be half of max size.
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java34
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java4
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/Flags.java4
4 files changed, 25 insertions, 19 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
index 413a7dbc62e..8ccd1e67ba1 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
@@ -120,7 +120,7 @@ public interface ModelContext {
default Duration jdiscHealthCheckProxyClientTimeout() { return Duration.ofMillis(100); }
// TODO(bjorncs): Temporary feature flag
- default double feedCoreThreadPoolSizeFactor() { return 1.0; }
+ default double feedCoreThreadPoolSizeFactor() { return 4.0; }
default Quota quota() {
return Quota.empty();
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java b/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java
index a4737c9f54c..f5eebc5be19 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/clients/ContainerDocumentApi.java
@@ -64,10 +64,9 @@ public class ContainerDocumentApi {
}
private static ThreadPoolExecutorComponent newExecutorComponent(String name, ContainerCluster<?> cluster, Options options) {
- int maxPoolSize = maxPoolSize(cluster);
return new ThreadPoolExecutorComponent.Builder(name)
- .maxPoolSize(maxPoolSize)
- .corePoolSize(corePoolSize(maxPoolSize, options))
+ .maxPoolSize(maxPoolSize(cluster, options))
+ .corePoolSize(corePoolSize(cluster, options))
.queueSize(500)
.build();
}
@@ -93,29 +92,36 @@ public class ContainerDocumentApi {
return handler;
}
- private static int maxPoolSize(ContainerCluster<?> cluster) {
+ private static int maxPoolSize(ContainerCluster<?> cluster, Options options) {
+ double vcpu = vcpu(cluster);
+ if (vcpu == 0) return FALLBACK_MAX_POOL_SIZE;
+ return Math.max(2, (int)Math.ceil(vcpu * options.feedThreadPoolSizeFactory));
+ }
+
+ private static int corePoolSize(ContainerCluster<?> cluster, Options options) {
+ double vcpu = vcpu(cluster);
+ if (vcpu == 0) return FALLBACK_CORE_POOL_SIZE;
+ return Math.max(1, (int)Math.ceil(vcpu * options.feedThreadPoolSizeFactory * 0.5));
+ }
+
+ private static double vcpu(ContainerCluster<?> cluster) {
List<Double> vcpus = cluster.getContainers().stream()
.filter(c -> c.getHostResource() != null && c.getHostResource().realResources() != null)
.map(c -> c.getHostResource().realResources().vcpu())
.distinct()
.collect(Collectors.toList());
// We can only use host resource for calculation if all container nodes in the cluster are homogeneous (in terms of vcpu)
- if (vcpus.size() != 1 || vcpus.get(0) == 0) return FALLBACK_MAX_POOL_SIZE;
- return Math.max(2, (int)Math.ceil(vcpus.get(0)));
- }
-
- private static int corePoolSize(int maxPoolSize, Options options) {
- if (maxPoolSize == FALLBACK_MAX_POOL_SIZE) return FALLBACK_CORE_POOL_SIZE;
- return Math.max(1, (int)Math.ceil(options.feedCoreThreadPoolSizeFactor * maxPoolSize));
+ if (vcpus.size() != 1 || vcpus.get(0) == 0) return 0;
+ return vcpus.get(0);
}
public static final class Options {
private final Collection<String> bindings;
- private final double feedCoreThreadPoolSizeFactor;
+ private final double feedThreadPoolSizeFactory;
- public Options(Collection<String> bindings, double feedCoreThreadPoolSizeFactor) {
+ public Options(Collection<String> bindings, double feedThreadPoolSizeFactory) {
this.bindings = Collections.unmodifiableCollection(bindings);
- this.feedCoreThreadPoolSizeFactor = feedCoreThreadPoolSizeFactor;
+ this.feedThreadPoolSizeFactory = feedThreadPoolSizeFactory;
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java
index 37e5dc21346..ab73309bb7d 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerDocumentApiBuilderTest.java
@@ -116,8 +116,8 @@ public class ContainerDocumentApiBuilderTest extends ContainerModelBuilderTestBa
assertThat(injectedComponentIds, hasItem("threadpool@feedapi-handler"));
ThreadpoolConfig config = root.getConfig(ThreadpoolConfig.class, "cluster1/component/com.yahoo.vespa.http.server.FeedHandler/threadpool@feedapi-handler");
- assertEquals(4, config.maxthreads());
- assertEquals(4, config.corePoolSize());
+ assertEquals(16, config.maxthreads());
+ assertEquals(8, config.corePoolSize());
}
private static class HostProvisionerWithCustomRealResource implements HostProvisioner {
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
index f33ca549cf7..b7c7fc5ff15 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
@@ -346,8 +346,8 @@ public class Flags {
);
public static final UnboundDoubleFlag FEED_CORE_THREAD_POOL_SIZE_FACTOR = defineDoubleFlag(
- "feed-core-thread-pool-size-factor", 1.0,
- "Number of core threads in threadpool for feeding APIs as factor of max pool size",
+ "feed-core-thread-pool-size-factor", 4.0,
+ "Max threads in threadpool for feeding APIs as a factor of vcpu",
"Takes effect on next internal redeployment",
APPLICATION_ID);