From 3ec254e908473b370b395e035b55ab73134bc16c Mon Sep 17 00:00:00 2001 From: bgamard Date: Wed, 6 May 2020 11:35:45 +0200 Subject: [PATCH] #400: limit async bus to (cpu cores / 2) threads --- .../java/com/sismics/docs/core/model/context/AppContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java b/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java index 0b191b82..71a168a4 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java +++ b/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java @@ -5,7 +5,6 @@ import com.google.common.eventbus.AsyncEventBus; import com.google.common.eventbus.EventBus; import com.sismics.docs.core.constant.Constants; import com.sismics.docs.core.dao.UserDao; -import com.sismics.docs.core.event.RebuildIndexAsyncEvent; import com.sismics.docs.core.listener.async.*; import com.sismics.docs.core.model.jpa.User; import com.sismics.docs.core.service.FileService; @@ -172,7 +171,8 @@ public class AppContext { if (EnvironmentUtil.isUnitTest()) { return new EventBus(); } else { - ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 8, + int threadCount = Runtime.getRuntime().availableProcessors() / 2; + ThreadPoolExecutor executor = new ThreadPoolExecutor(threadCount, threadCount, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>()); asyncExecutorList.add(executor);