From ea998bf77a853cdaa1dcf4d5c4c957154b2195e7 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 26 Jan 2012 11:34:15 +0100 Subject: [PATCH] more reasonable thread pool logging --- .../openapi/application/impl/ApplicationImpl.java | 8 +++++++- .../platform-resources-en/src/misc/registry.properties | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index feeabc285a35..88e5bf57d91c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -50,6 +50,7 @@ import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; @@ -78,6 +79,7 @@ import java.lang.reflect.Method; import java.util.List; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; @SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"}) public class ApplicationImpl extends ComponentManagerImpl implements ApplicationEx { @@ -117,6 +119,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application private final AtomicBoolean mySaveSettingsIsInProgress = new AtomicBoolean(false); @SuppressWarnings({"UseOfArchaicSystemPropertyAccessors"}) private static final int ourDumpThreadsOnLongWriteActionWaiting = Integer.getInteger("dump.threads.on.long.write.action.waiting", 0); + private final AtomicInteger myAliveThreads = new AtomicInteger(0); + private static final int ourReasonableThreadPoolSize = Registry.intValue("core.pooled.threads"); private final ExecutorService ourThreadExecutorsService = new ThreadPoolExecutor( 3, @@ -127,6 +131,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application new ThreadFactory() { int i; public Thread newThread(Runnable r) { + final int count = myAliveThreads.incrementAndGet(); final Thread thread = new Thread(r, "ApplicationImpl pooled thread "+i++) { public void interrupt() { if (LOG.isDebugEnabled()) { @@ -144,9 +149,10 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application LOG.debug("Worker exits due to exception", t); } } + myAliveThreads.decrementAndGet(); } }; - if (ApplicationInfoImpl.getShadowInstance().isEAP() && i > 10) { + if (ApplicationInfoImpl.getShadowInstance().isEAP() && count > ourReasonableThreadPoolSize) { LOG.info("Not enough pooled threads; creating one at:", new Throwable()); } thread.setPriority(Thread.NORM_PRIORITY - 1); diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index f27367c763ef..7cd59ea6ff8e 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -181,6 +181,7 @@ dump.threads.on.empty.lookup.description=Whether IDEA should issue a thread dump file.structure.tree.mode=true -python.new.style.resolve=false disable.toolwindow.overlayed=true -disable.toolwindow.overlayed.description=Disable transparent toolwindow stripes \ No newline at end of file +disable.toolwindow.overlayed.description=Disable transparent toolwindow stripes + +core.pooled.threads=20