diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-09-01 11:55:27 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-09-03 15:57:27 +0200 |
commit | 20a2be2b64e591680305d322a14f56e3d2d06d91 (patch) | |
tree | 08cd583f3e534555f21f81ae6b94445d82777f38 /config-model | |
parent | dea4b4b9ce2aaaadfdca6b8f933967f4b359da25 (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.
Diffstat (limited to 'config-model')
2 files changed, 22 insertions, 16 deletions
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 { |