Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix promotion calculation #242

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -324,6 +324,8 @@ private AbstractGCEvent<?> handleTagGcHeapTail(ParseContext context, AbstractGCE
parentEvent.setTotal(returnEvent.getTotal());
context.partialEventsMap.put(event.getNumber() + "", parentEvent);
returnEvent = null;
} else if(event.getExtendedType().getType().equals(Type.UJL_G1_OLD) && parentEvent != null) {
returnEvent = parseTail(context, event, tail);
}
return returnEvent;
}
25 changes: 17 additions & 8 deletions src/main/java/com/tagtraum/perf/gcviewer/model/GCModel.java
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.CollectionType;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Generation;

import static com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;

/**
* Collection of GCEvents.
*
@@ -642,19 +644,26 @@ private void setTimeStamp(VmOperationEvent vmOpEvent) {
private void updatePromotion(GCEvent event) {
if (event.getGeneration().equals(Generation.YOUNG) && event.hasDetails() && !event.isFull()) {

GCEvent youngEvent = null;
for (Iterator<GCEvent> i = event.details(); i.hasNext(); ) {
GCEvent ev = i.next();
if (ev.getGeneration().equals(Generation.YOUNG)) {
youngEvent = ev;
break;
if (ev.getGeneration().equals(Generation.TENURED) && ev.getTypeAsString().contains(Type.UJL_G1_OLD.getName())) {
int promoted = ev.getPostUsed() - ev.getPreUsed();
if(promoted > 0) {
this.promotion.add(promoted);
}
return;
}
}

if (youngEvent != null) {
promotion.add((youngEvent.getPreUsed() - youngEvent.getPostUsed())
- (event.getPreUsed() - event.getPostUsed())
);
// naive implementationa as fallback
for (Iterator<GCEvent> i = event.details(); i.hasNext(); ) {
GCEvent ev = i.next();
if (ev.getGeneration().equals(Generation.YOUNG)) {
promotion.add((ev.getPreUsed() - ev.getPostUsed())
- (event.getPreUsed() - event.getPostUsed())
);
return;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -180,4 +180,39 @@ public void testPauseYoungConcurrentStartMetadataGcThreshold() throws Exception
assertThat("event type", model.get(0).getExtendedType().getType(), is(Type.UJL_PAUSE_YOUNG));
assertThat("total heap", model.get(0).getTotal(), is(256 * 1024));
}

@Test
public void calculatePromotion() throws Exception {
TestLogHandler handler = new TestLogHandler();
handler.setLevel(Level.WARNING);
GCResource gcResource = new GcResourceFile("byteArray");
gcResource.getLogger().addHandler(handler);
InputStream in = new ByteArrayInputStream(
("[0.011s][info][gc,heap] Heap region size: 1M\n" +
"[0.023s][info][gc ] Using G1\n" +
"[0.023s][info][gc,heap,coops] Heap address: 0x0000000700000000, size: 4096 MB, Compressed Oops mode: Zero based, Oop shift amount: 3\n" +
"[18.700s][info][gc,start ] GC(12) Pause Young (Normal) (G1 Evacuation Pause)\n" +
"[18.700s][info][gc,task ] GC(12) Using 8 workers of 8 for evacuation\n" +
"[18.709s][info][gc,phases ] GC(12) Pre Evacuate Collection Set: 0.0ms\n" +
"[18.709s][info][gc,phases ] GC(12) Evacuate Collection Set: 7.8ms\n" +
"[18.709s][info][gc,phases ] GC(12) Post Evacuate Collection Set: 0.9ms\n" +
"[18.709s][info][gc,phases ] GC(12) Other: 0.2ms\n" +
"[18.709s][info][gc,heap ] GC(12) Eden regions: 137->0(140)\n" +
"[18.709s][info][gc,heap ] GC(12) Survivor regions: 16->13(20)\n" +
"[18.709s][info][gc,heap ] GC(12) Old regions: 8->13\n" +
"[18.709s][info][gc,heap ] GC(12) Humongous regions: 18->8\n" +
"[18.709s][info][gc,metaspace ] GC(12) Metaspace: 48235K->48235K(1093632K)\n" +
"[18.709s][info][gc ] GC(12) Pause Young (Normal) (G1 Evacuation Pause) 177M->32M(256M) 9.073ms\n" +
"[18.709s][info][gc,cpu ] GC(12) User=0.00s Sys=0.00s Real=0.01s")
.getBytes());

DataReader reader = new DataReaderUnifiedJvmLogging(gcResource, in);
GCModel model = reader.read();

assertThat("number of warnings", handler.getCount(), is(0));
assertThat("number of events", model.size(), is(1));
assertThat("event type", model.get(0).getExtendedType().getType(), is(Type.UJL_PAUSE_YOUNG));
assertThat("total heap", model.get(0).getTotal(), is(256 * 1024));
assertThat("promotion", model.getPromotion().getSum(), is(new Long(5 * 1024)));
}
}