Skip to content

Commit 5ab8fcc

Browse files
committed
Merge branch 'master' into graal
2 parents 4fe2486 + bdb2bc9 commit 5ab8fcc

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/StackTraceSnapshotBuilder.java

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -727,33 +727,49 @@ protected long getDumpAbsTimeStamp() {
727727
@Override
728728
protected void applyDiffAtGetResultsMoment(ThreadInfo ti) {
729729
long time0 = getDumpAbsTimeStamp();
730-
long diff = time0 - ti.topMethodEntryTime0;
730+
long diff0 = time0 - ti.topMethodEntryTime0;
731+
long diff1 = getThreadTime(ti, diff0) - ti.topMethodEntryTime1;
731732

732-
if (diff>0) {
733-
applyDiffToTopNode(ti, diff);
734-
ti.diffAtGetResultsMoment = diff;
733+
if (diff0<0) diff0=0;
734+
if (diff1<0) diff1=0;
735+
if (diff0>0 || diff1>0) {
736+
applyDiffToTopNode(ti, diff0, diff1);
737+
ti.diffAtGetResultsMoment0 = diff0;
738+
ti.diffAtGetResultsMoment1 = diff1;
735739
}
736740
}
737741

738742
@Override
739743
protected void undoDiffAtGetResultsMoment(ThreadInfo ti) {
740-
if (ti.diffAtGetResultsMoment>0) {
741-
applyDiffToTopNode(ti, -ti.diffAtGetResultsMoment);
742-
ti.diffAtGetResultsMoment = 0;
744+
if (ti.diffAtGetResultsMoment0>0) {
745+
applyDiffToTopNode(ti, -ti.diffAtGetResultsMoment0, -ti.diffAtGetResultsMoment1);
746+
ti.diffAtGetResultsMoment0 = 0;
743747
}
744748
}
745749

746-
private void applyDiffToTopNode(ThreadInfo ti, long diff) {
750+
private long getThreadTime(ThreadInfo ti, long diff0) {
751+
if (isCollectingTwoTimeStamps()) {
752+
SampledThreadInfo sti = lastStackTrace.get().get(Long.valueOf(ti.threadId));
753+
754+
if (sti!=null) {
755+
if (sti.threadCpuTime != -1) {
756+
return sti.threadCpuTime;
757+
}
758+
if (sti.getThreadState() == Thread.State.RUNNABLE) {
759+
return diff0;
760+
}
761+
}
762+
}
763+
return 0;
764+
}
765+
766+
private void applyDiffToTopNode(ThreadInfo ti, long diff0, long diff1) {
747767
TimedCPUCCTNode top = ti.peek();
748768

749769
if (top instanceof MethodCPUCCTNode) {
750-
top.addNetTime0(diff);
770+
top.addNetTime0(diff0);
751771
if (isCollectingTwoTimeStamps()) {
752-
SampledThreadInfo sti = lastStackTrace.get().get(Long.valueOf(ti.threadId));
753-
754-
if (sti!=null && sti.getThreadState() == Thread.State.RUNNABLE) {
755-
top.addNetTime1(diff);
756-
}
772+
top.addNetTime1(diff1);
757773
}
758774
}
759775
}

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/ThreadInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public class ThreadInfo {
5252
// processing of data is resumed, we need to subtract this value back from that node.
5353
// This is effectively the self time for the last invocation of the top method on stack - if we would not keep
5454
// it separately, it would not be reported
55-
long diffAtGetResultsMoment; // diff between last methodEntry and current moment timestamp -
56-
// we will have to compensate for the processing time
55+
long diffAtGetResultsMoment0; // diff between last methodEntry and current moment timestamp - we will have to compensate for the processing time
56+
long diffAtGetResultsMoment1; // as above, but for thread CPU time
5757

5858
//~ Instance fields ------------------------------------------------------------------------------------------------------
5959
final private Object stackLock = new Object();

visualvm/tools/src/org/graalvm/visualvm/tools/jvmstat/JvmstatModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* This class uses Jvmstat technology
3333
* (http://java.sun.com/performance/jvmstat/)
34-
* to obtatin various information from JVM. Note that
34+
* to obtain various information from JVM. Note that
3535
* Jvmstat is available in JDK 1.4.2 and up. It is also available for
3636
* remote Java applications if
3737
* <a href=http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jstatd.html>jstatd daemon</a>

0 commit comments

Comments
 (0)