generate dumps only first 3 minutes to avoid lots of garbage files

GitOrigin-RevId: fbd4c461e013b4eb2bfeddd41d6845808fedae68
This commit is contained in:
Egor Ushakov
2019-07-16 15:41:58 +03:00
committed by intellij-monorepo-bot
parent 96453b2009
commit e0b382a7dc
3 changed files with 24 additions and 4 deletions
@@ -161,7 +161,7 @@ public class PerformanceWatcher implements Disposable {
private static boolean shouldWatch() {
return !ApplicationManager.getApplication().isHeadlessEnvironment() &&
Registry.intValue("performance.watcher.unresponsive.interval.ms") != 0 &&
getUnresponsiveInterval() != 0 &&
getMaxAttempts() != 0;
}
@@ -211,8 +211,16 @@ public class PerformanceWatcher implements Disposable {
return getSamplingInterval() * getMaxAttempts();
}
static int getUnresponsiveInterval() {
return Registry.intValue("performance.watcher.unresponsive.interval.ms");
}
static int getMaxDumpDuration() {
return Registry.intValue("performance.watcher.dump.duration.s") * 1000;
}
private void edtFrozen(long currentMillis) {
if (currentMillis - myLastDumpTime >= Registry.intValue("performance.watcher.unresponsive.interval.ms")) {
if (currentMillis - myLastDumpTime >= getUnresponsiveInterval()) {
myLastDumpTime = currentMillis;
if (myFreezeStart == 0) {
myFreezeStart = myLastEdtAlive;
@@ -274,7 +282,7 @@ public class PerformanceWatcher implements Disposable {
myCurrentEDTEventChecker.cancel(false);
}
myCurrentEDTEventChecker = myExecutor
.schedule(() -> edtFrozenPrecise(start), Registry.intValue("performance.watcher.unresponsive.interval.ms"), TimeUnit.MILLISECONDS);
.schedule(() -> edtFrozenPrecise(start), getUnresponsiveInterval(), TimeUnit.MILLISECONDS);
}
}
@@ -303,6 +311,9 @@ public class PerformanceWatcher implements Disposable {
private void dumpThreads() {
dumpThreads(getFreezeFolderName(myFreezeStart) + "/", false);
if (System.currentTimeMillis() - myFreezeStart > getMaxDumpDuration()) {
stopDumping();
}
}
@Nullable
@@ -74,9 +74,12 @@ public class IdeaFreezeReporter {
}
myDumpTask.cancel();
int lengthInSeconds = (int)(durationMs / 1000);
long dumpingDuration = durationMs - PerformanceWatcher.getUnresponsiveInterval();
if (lengthInSeconds > FREEZE_THRESHOLD &&
// check that we have at least half of the dumps required
myCurrentDumps.size() >= Math.max(3, lengthInSeconds * 500 / Registry.intValue("performance.watcher.unresponsive.interval.ms")) &&
(myDumpTask.isValid(dumpingDuration) ||
myCurrentDumps.size() >=
Math.max(3, Math.min(PerformanceWatcher.getMaxDumpDuration(), dumpingDuration / 2) / PerformanceWatcher.getDumpInterval())) &&
!ContainerUtil.isEmpty(myStacktraceCommonPart)) {
int size = Math.min(myCurrentDumps.size(), 20); // report up to 20 dumps
int step = myCurrentDumps.size() / size;
@@ -301,6 +304,10 @@ public class IdeaFreezeReporter {
}
}
boolean isValid(long dumpingDuration) {
return myThreadInfos.size() >= Math.max(10, Math.min(myMaxDumps, dumpingDuration / myDumpInterval / 2));
}
void cancel() {
myFuture.cancel(false);
}
@@ -1524,6 +1524,8 @@ performance.watcher.unresponsive.max.attempts.before.log.description=If the prod
performance.watcher.sampling.interval.ms=1000
performance.watcher.sampling.interval.ms.description=If the product is unresponsive for performance.watcher.unresponsive.max.attempts.before.log * performance.watcher.sampling.interval.ms, dump threads every performance.watcher.sampling.interval.ms
performance.watcher.dump.duration.s=180
performance.watcher.dump.duration.s.description=If the product is unresponsive, dump threads for the specified amount of time
performance.watcher.precise=true
performance.watcher.precise.restartRequired=true