Dieser Commit ist enthalten in:
Ursprung
80937cdfd8
Commit
6da60b9165
@ -10,7 +10,7 @@ import java.util.concurrent.locks.LockSupport;
|
|||||||
public class Sampler {
|
public class Sampler {
|
||||||
|
|
||||||
public static final long SAMPLING_SPEED = 1000000;
|
public static final long SAMPLING_SPEED = 1000000;
|
||||||
public static final double FILTER = 0.01;
|
public static final int FILTER = 10;
|
||||||
|
|
||||||
private static final Set<String> waitingMethods = new HashSet<>();
|
private static final Set<String> waitingMethods = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
@ -38,14 +38,9 @@ public class Sampler {
|
|||||||
omittedMethods.add("java.lang.Iterable.forEach");
|
omittedMethods.add("java.lang.Iterable.forEach");
|
||||||
omittedMethods.add("java.util.ArrayList.forEach");
|
omittedMethods.add("java.util.ArrayList.forEach");
|
||||||
omittedMethods.add("java.util.Map.forEach");
|
omittedMethods.add("java.util.Map.forEach");
|
||||||
|
omittedMethods.add("java.util.concurrent.ThreadPoolExecutor$Worker.run");
|
||||||
//TODO: Rework to concrete functions
|
omittedMethods.add("java.util.concurrent.ThreadPoolExecutor.runWorker");
|
||||||
omittedMethods.add("jdk.internal");
|
omittedMethods.add("java.util.concurrent.CompletableFuture$Completion.run");
|
||||||
omittedMethods.add("java.util.stream");
|
|
||||||
omittedMethods.add("java.util.Spliterators");
|
|
||||||
omittedMethods.add("java.util.ArrayList$ArrayListSpliterator");
|
|
||||||
omittedMethods.add("java.util.AbstractList$RandomAccessSpliterator");
|
|
||||||
omittedMethods.add("java.util.concurrent");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<String, Trace> traces = new HashMap<>();
|
private final Map<String, Trace> traces = new HashMap<>();
|
||||||
@ -93,8 +88,6 @@ public class Sampler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
private void run() {
|
||||||
Thread autoStopper = new Thread(this::stop, "SamplerStop");
|
|
||||||
Runtime.getRuntime().addShutdownHook(autoStopper);
|
|
||||||
long lastTime = System.nanoTime();
|
long lastTime = System.nanoTime();
|
||||||
while(!shutdown) {
|
while(!shutdown) {
|
||||||
sample();
|
sample();
|
||||||
@ -103,12 +96,6 @@ public class Sampler {
|
|||||||
LockSupport.parkNanos(SAMPLING_SPEED - currentTime + lastTime);
|
LockSupport.parkNanos(SAMPLING_SPEED - currentTime + lastTime);
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
Runtime.getRuntime().removeShutdownHook(autoStopper);
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sample() {
|
private void sample() {
|
||||||
|
@ -30,7 +30,7 @@ public class Trace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean filtered() {
|
private boolean filtered() {
|
||||||
return Arrays.stream(samples).sum() / (double) sampler.getSampleRuns() < Sampler.FILTER;
|
return Arrays.stream(samples).sum() < Sampler.FILTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Thread.State state, Trace predecessor) {
|
public void add(Thread.State state, Trace predecessor) {
|
||||||
@ -62,7 +62,7 @@ public class Trace {
|
|||||||
writer.append(String.valueOf(id)).append(" [fillcolor=\"#").append(String.format("%02X", r)).append(String.format("%02X", g)).append(String.format("%02X", b)).append(String.format("%02X", a)).append("\",label=\"").append(name).append("\\n").append(percentage(ownSampleRuns())).append("% ").append(df.format(ownSampleRuns() * Sampler.SAMPLING_SPEED / 1e9)).append("s\\nR").append(percentage(runnable)).append("% B").append(percentage(blocked)).append("% W").append(percentage(waiting)).append("%\"];\n");
|
writer.append(String.valueOf(id)).append(" [fillcolor=\"#").append(String.format("%02X", r)).append(String.format("%02X", g)).append(String.format("%02X", b)).append(String.format("%02X", a)).append("\",label=\"").append(name).append("\\n").append(percentage(ownSampleRuns())).append("% ").append(df.format(ownSampleRuns() * Sampler.SAMPLING_SPEED / 1e9)).append("s\\nR").append(percentage(runnable)).append("% B").append(percentage(blocked)).append("% W").append(percentage(waiting)).append("%\"];\n");
|
||||||
|
|
||||||
for (Map.Entry<Trace, Integer> entry : predecessors.entrySet()) {
|
for (Map.Entry<Trace, Integer> entry : predecessors.entrySet()) {
|
||||||
if (entry.getKey().filtered() || entry.getValue() / (double)sampler.getSampleRuns() < Sampler.FILTER)
|
if (entry.getKey().filtered() || entry.getValue() < Sampler.FILTER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
writer.append(String.valueOf(entry.getKey().id)).append(" -> ").append(String.valueOf(id)).append(" [label=\"").append(percentage(entry.getValue())).append("%\",weight=").append(String.valueOf(entry.getValue())).append("];\n");
|
writer.append(String.valueOf(entry.getKey().id)).append(" -> ").append(String.valueOf(id)).append(" [label=\"").append(percentage(entry.getValue())).append("%\",weight=").append(String.valueOf(entry.getValue())).append("];\n");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren