blob: 2ca97b297b0546da0125083ff005a3f3a166f63c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.container.handler.ThreadPoolProvider;
import com.yahoo.container.handler.ThreadpoolConfig;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.component.SimpleComponent;
/**
* Component definition for the jdisc default threadpool provider ({@link ThreadPoolProvider}).
*
* @author bjorncs
*/
class DefaultThreadpoolProvider extends SimpleComponent implements ThreadpoolConfig.Producer {
private final ContainerCluster<?> cluster;
DefaultThreadpoolProvider(ContainerCluster<?> cluster) {
super(new ComponentModel(
BundleInstantiationSpecification.getFromStrings(
"default-threadpool",
ThreadPoolProvider.class.getName(),
null)));
this.cluster = cluster;
}
@Override
public void getConfig(ThreadpoolConfig.Builder builder) {
if (!(cluster instanceof ApplicationContainerCluster)) {
// Container clusters such as logserver, metricsproxy and clustercontroller
int defaultWorkerThreads = 10;
builder.maxthreads(defaultWorkerThreads);
builder.corePoolSize(defaultWorkerThreads);
builder.queueSize(50);
return;
}
double vcpu = cluster.vcpu().orElse(0);
if (vcpu == 0) return;
// Configuration is currently identical to the search handler's threadpool
int workerThreads = Math.max(8, (int)Math.ceil(vcpu * 2.0));
builder.maxthreads(workerThreads);
builder.corePoolSize(workerThreads);
builder.queueSize((int)(workerThreads * 40.0));
}
}
|