diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-06-03 16:20:03 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-06-03 17:10:39 +0200 |
commit | b2b874ebabfcecffbfeece5623048d9dca597e65 (patch) | |
tree | 3791c11c65ca29c3050a63b607c2d27896d8c611 /container-core/src | |
parent | a9a3cadedbf5c5270fcf8541eb37e8ef69ea57f0 (diff) |
Add config for core pool size
Diffstat (limited to 'container-core/src')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/threadpool/ContainerThreadPool.java | 12 | ||||
-rw-r--r-- | container-core/src/main/resources/configdefinitions/threadpool.def | 5 |
2 files changed, 13 insertions, 4 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/threadpool/ContainerThreadPool.java b/container-core/src/main/java/com/yahoo/container/handler/threadpool/ContainerThreadPool.java index 45b55a8a150..6251f1975dd 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/threadpool/ContainerThreadPool.java +++ b/container-core/src/main/java/com/yahoo/container/handler/threadpool/ContainerThreadPool.java @@ -32,9 +32,10 @@ public class ContainerThreadPool extends AbstractComponent implements AutoClosea } public ContainerThreadPool(ThreadpoolConfig threadpoolConfig, Metric metric, ProcessTerminator processTerminator) { - int maxNumThreads = computeThreadPoolSize(threadpoolConfig.maxthreads()); + int maxNumThreads = computeMaximumThreadPoolSize(threadpoolConfig.maxthreads()); + int coreNumThreads = computeCoreThreadPoolSize(threadpoolConfig.corePoolSize(), maxNumThreads); WorkerCompletionTimingThreadPoolExecutor executor = - new WorkerCompletionTimingThreadPoolExecutor(maxNumThreads, maxNumThreads, + new WorkerCompletionTimingThreadPoolExecutor(coreNumThreads, maxNumThreads, 0L, TimeUnit.SECONDS, createQ(threadpoolConfig.queueSize(), maxNumThreads), ThreadFactoryFactory.getThreadFactory(threadpoolConfig.name()), @@ -79,9 +80,14 @@ public class ContainerThreadPool extends AbstractComponent implements AutoClosea : new ArrayBlockingQueue<>(queueSize); } - private static int computeThreadPoolSize(int maxNumThreads) { + private static int computeMaximumThreadPoolSize(int maxNumThreads) { return (maxNumThreads <= 0) ? Runtime.getRuntime().availableProcessors() * 4 : maxNumThreads; } + + private static int computeCoreThreadPoolSize(int corePoolSize, int maxNumThreads) { + return Math.min(corePoolSize, maxNumThreads); + } + } diff --git a/container-core/src/main/resources/configdefinitions/threadpool.def b/container-core/src/main/resources/configdefinitions/threadpool.def index b3202ebfecc..7d57cd3e35c 100644 --- a/container-core/src/main/resources/configdefinitions/threadpool.def +++ b/container-core/src/main/resources/configdefinitions/threadpool.def @@ -2,10 +2,13 @@ namespace=container.handler -## Num ber of thread in the thread pool +## Maximum number of thread in the thread pool ## Setting it to 0 or negative number will cause it to be set to #cores * 4 maxthreads int default=500 +# The number of threads to keep in the pool, even if they are idle +corePoolSize int default=500 + ## max queue size ## There can be queueSize + maxthreads requests inflight concurrently ## The container will start replying 503 |