Skip to content

Commit

Permalink
Reduce lagSpikeMillis to 200. Fix lag spike profiling never ending
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Feb 14, 2016
1 parent e4bab6e commit 3723fda
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

public class LagSpikeProfiler {
private static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0];
private static final int deadLockMillis = 400;
private static final long deadLockNanoSeconds = TimeUnit.SECONDS.toNanos(deadLockMillis);
private static final int lagSpikeMillis = 200;
private static final long lagSpikeNanoSeconds = TimeUnit.SECONDS.toNanos(lagSpikeMillis);
private static boolean inProgress;
private static volatile long lastTickTime = 0;
private final ICommandSender commandSender;
Expand Down Expand Up @@ -189,14 +189,17 @@ private static String toString(ThreadInfo threadInfo, boolean name) {
}

private void start() {
final int sleepTime = Math.max(1000, (deadLockMillis * 1000) / 6);
final int sleepTime = Math.max(1000, (lagSpikeMillis * 1000) / 6);
Thread detectorThread = new Thread(new Runnable() {
@Override
public void run() {
trySleep(60000);
while (!stopping && checkForLagSpikes()) {
trySleep(sleepTime);
}
synchronized (LagSpikeProfiler.class) {
inProgress = false;
}
}
});
detectorThread.setName("Lag Spike Detector");
Expand All @@ -214,7 +217,7 @@ boolean checkForLagSpikes() {
return false;

long deadTime = time - lastTickTime;
if (deadTime < deadLockNanoSeconds) {
if (deadTime < lagSpikeNanoSeconds) {
detected = false;
return true;
}
Expand Down

0 comments on commit 3723fda

Please sign in to comment.