mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
avoid too many coroutine dispatch idle threads littering thread dump
GitOrigin-RevId: 5a7afb198e9b2bc03f53f9a55f777c2981dd65d8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
49e238388a
commit
04c31dddfb
@@ -107,15 +107,33 @@ public final class ThreadDumper {
|
|||||||
StackTraceElement[] edtStack = null;
|
StackTraceElement[] edtStack = null;
|
||||||
for (ThreadInfo info : threadInfo) {
|
for (ThreadInfo info : threadInfo) {
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
if (isEDT(info)) {
|
String name = info.getThreadName();
|
||||||
edtStack = info.getStackTrace();
|
StackTraceElement[] stackTrace = info.getStackTrace();
|
||||||
|
if (edtStack == null && isEDT(name)) {
|
||||||
|
edtStack = stackTrace;
|
||||||
}
|
}
|
||||||
dumpThreadInfo(info, f);
|
if (isIdleDefaultCoroutineDispatch(name, stackTrace)) {
|
||||||
|
// avoid 64 coroutine dispatch idle threads littering thread dump
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dumpCallStack(info, f, stackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return edtStack;
|
return edtStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isIdleDefaultCoroutineDispatch(String name, StackTraceElement @NotNull [] stackTrace) {
|
||||||
|
return name != null && name.startsWith("DefaultDispatcher-worker-")
|
||||||
|
&& stackTrace.length == 6
|
||||||
|
&& stackTrace[0].isNativeMethod() && stackTrace[0].getMethodName().equals("park") && stackTrace[0].getClassName().equals("jdk.internal.misc.Unsafe")
|
||||||
|
&& stackTrace[1].getMethodName().equals("parkNanos") && stackTrace[1].getClassName().equals("java.util.concurrent.locks.LockSupport")
|
||||||
|
&& stackTrace[2].getMethodName().equals("park") && stackTrace[2].getClassName().equals("kotlinx.coroutines.scheduling.CoroutineScheduler$Worker")
|
||||||
|
&& stackTrace[3].getMethodName().equals("tryPark") && stackTrace[3].getClassName().equals("kotlinx.coroutines.scheduling.CoroutineScheduler$Worker")
|
||||||
|
&& stackTrace[4].getMethodName().equals("runWorker") && stackTrace[4].getClassName().equals("kotlinx.coroutines.scheduling.CoroutineScheduler$Worker")
|
||||||
|
&& stackTrace[5].getMethodName().equals("run") && stackTrace[5].getClassName().equals("kotlinx.coroutines.scheduling.CoroutineScheduler$Worker")
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
public static ThreadInfo @NotNull [] sort(@NotNull ThreadInfo @NotNull [] threads) {
|
public static ThreadInfo @NotNull [] sort(@NotNull ThreadInfo @NotNull [] threads) {
|
||||||
Arrays.sort(threads, Comparator
|
Arrays.sort(threads, Comparator
|
||||||
|
|||||||
Reference in New Issue
Block a user