aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/handler/threadpool
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2021-09-30 14:57:23 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2021-09-30 14:57:23 +0200
commita30849486a1a6e4639193297b6972457ff242a89 (patch)
treec5bf505d15bb9bf07306f5f9a06aacc067b6e6df /container-core/src/test/java/com/yahoo/container/handler/threadpool
parent9c113ad7ea0f5181f0d82933f6d08dc8f7637ef6 (diff)
Scale jdisc threadpools with cpus available in JVM
Change config model to only determine the scaling factors for all threadpool configuration.
Diffstat (limited to 'container-core/src/test/java/com/yahoo/container/handler/threadpool')
-rw-r--r--container-core/src/test/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadPoolTest.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/container-core/src/test/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadPoolTest.java b/container-core/src/test/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadPoolTest.java
index 8b1ed12c796..1d9c4b367bd 100644
--- a/container-core/src/test/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadPoolTest.java
+++ b/container-core/src/test/java/com/yahoo/container/handler/threadpool/DefaultContainerThreadPoolTest.java
@@ -21,6 +21,9 @@ import static org.junit.Assert.fail;
* @author bjorncs
*/
public class DefaultContainerThreadPoolTest {
+
+ private static final int CPUS = 16;
+
@Test
public final void testThreadPool() throws InterruptedException {
ContainerThreadpoolConfig config = new ContainerThreadpoolConfig(new ContainerThreadpoolConfig.Builder().maxThreads(1));
@@ -55,8 +58,12 @@ public class DefaultContainerThreadPoolTest {
}
private ThreadPoolExecutor createPool(int maxThreads, int queueSize) {
- ContainerThreadpoolConfig config = new ContainerThreadpoolConfig(new ContainerThreadpoolConfig.Builder().maxThreads(maxThreads).queueSize(queueSize));
- ContainerThreadPool threadPool = new DefaultContainerThreadpool(config, Mockito.mock(Metric.class));
+ ContainerThreadpoolConfig config = new ContainerThreadpoolConfig(new ContainerThreadpoolConfig.Builder()
+ .maxThreads(maxThreads)
+ .minThreads(maxThreads)
+ .queueSize(queueSize));
+ ContainerThreadPool threadPool = new DefaultContainerThreadpool(
+ config, Mockito.mock(Metric.class), new MockProcessTerminator(), CPUS);
ExecutorServiceWrapper wrapper = (ExecutorServiceWrapper) threadPool.executor();
WorkerCompletionTimingThreadPoolExecutor executor = (WorkerCompletionTimingThreadPoolExecutor)wrapper.delegate();
return executor;
@@ -64,27 +71,27 @@ public class DefaultContainerThreadPoolTest {
@Test
public void testThatThreadPoolSizeFollowsConfig() {
- ThreadPoolExecutor executor = createPool(3, 9);
+ ThreadPoolExecutor executor = createPool(3, 1200);
assertEquals(3, executor.getMaximumPoolSize());
- assertEquals(9, executor.getQueue().remainingCapacity());
+ assertEquals(1200, executor.getQueue().remainingCapacity());
}
@Test
public void testThatThreadPoolSizeAutoDetected() {
ThreadPoolExecutor executor = createPool(0, 0);
- assertEquals(Runtime.getRuntime().availableProcessors()*4, executor.getMaximumPoolSize());
+ assertEquals(CPUS*4, executor.getMaximumPoolSize());
assertEquals(0, executor.getQueue().remainingCapacity());
}
@Test
public void testThatQueueSizeAutoDetected() {
- ThreadPoolExecutor executor = createPool(3, -1);
- assertEquals(3, executor.getMaximumPoolSize());
- assertEquals(executor.getMaximumPoolSize()*4, executor.getQueue().remainingCapacity());
+ ThreadPoolExecutor executor = createPool(24, -50);
+ assertEquals(24, executor.getMaximumPoolSize());
+ assertEquals(24*50, executor.getQueue().remainingCapacity());
}
@Test
public void testThatThreadPoolSizeAndQueueSizeAutoDetected() {
- ThreadPoolExecutor executor = createPool(0, -1);
- assertEquals(Runtime.getRuntime().availableProcessors()*4, executor.getMaximumPoolSize());
- assertEquals(executor.getMaximumPoolSize()*4, executor.getQueue().remainingCapacity());
+ ThreadPoolExecutor executor = createPool(0, -100);
+ assertEquals(CPUS*4, executor.getMaximumPoolSize());
+ assertEquals(CPUS*4*100, executor.getQueue().remainingCapacity());
}
private class FlipIt implements Runnable {