use of com.tagtraum.perf.gcviewer.model.GCEvent in project GCViewer by chewiebug.
the class DataReaderHPUX1_2 method read.
public GCModel read() throws IOException {
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading HP-UX 1.2-1.4.0 format...");
try {
GCModel model = new GCModel();
model.setFormat(GCModel.Format.SUN_X_LOG_GC);
String line = null;
GCEvent event = null;
while ((line = in.readLine()) != null && shouldContinue()) {
StringTokenizer st = new StringTokenizer(line, " ");
if (st.countTokens() != 20) {
if (getLogger().isLoggable(Level.WARNING))
getLogger().warning("Malformed line (" + in.getLineNumber() + "). Wrong number of tokens (" + st.countTokens() + "): " + line);
continue;
}
if (!"<GC:".equals(st.nextToken())) {
if (getLogger().isLoggable(Level.WARNING))
getLogger().warning("Malformed line (" + in.getLineNumber() + "). Expected \"<GC:\" in " + line);
continue;
}
event = new GCEvent();
/*
%1: Indicates the cause of the garbage collection.
-1: indicates a Scavenge (GC of New Generation only)
0-6: indicates a Full GC (collection of all spaces in the
Java Heap)
Reason:
0: Call to System.gc
1: Old Generation full
2: Permanent Generation full
3: Train Generation full
4: Old generation expanded on last scavenge
5: Old generation too full to scavenge
6: FullGCAlot
*/
final int reason = Integer.parseInt(st.nextToken());
event.setType(findType(reason));
// %2: Program time at the beginning of the collection, in seconds
event.setTimestamp(NumberParser.parseDouble(st.nextToken()));
// %3: Garbage collection invocation. Counts of Scavenge and
// Full GCs are maintained separately
st.nextToken();
// %4: Size of the object allocation request that forced the GC, in bytes
st.nextToken();
// %5: Tenuring threshold - determines how long the new born object
// remains in the New Generation
st.nextToken();
// Eden Sub-space (within the New Generation)
// %6: Before
// %7: After
// %8: Capacity
final long edenBefore = Long.parseLong(st.nextToken());
final long edenAfter = Long.parseLong(st.nextToken());
final long edenCapacity = Long.parseLong(st.nextToken());
/*
GCEvent edenEvent = new GCEvent();
edenEvent.setType(AbstractGCEvent.Type.DEF_NEW);
edenEvent.setPreUsed((int)(edenBefore / 1024));
edenEvent.setPostUsed((int)(edenAfter / 1024));
edenEvent.setTotal((int)(edenCapacity / 1024));
*/
// Survivor Sub-space (within the New Generation)
// %9: Before
// %10: After
// %11: Capacity
final long survivorBefore = Long.parseLong(st.nextToken());
final long survivorAfter = Long.parseLong(st.nextToken());
final long survivorCapacity = Long.parseLong(st.nextToken());
/*
GCEvent survivorEvent = new GCEvent();
survivorEvent.setType(AbstractGCEvent.Type.DEF_NEW);
survivorEvent.setPreUsed((int)(survivorBefore / 1024));
survivorEvent.setPostUsed((int)(survivorAfter / 1024));
survivorEvent.setTotal((int)(survivorCapacity / 1024));
*/
// Since we don't distinguish between survivor spaces and eden, we add things up.
GCEvent newEvent = new GCEvent();
newEvent.setType(AbstractGCEvent.Type.DEF_NEW);
newEvent.setPreUsed((int) ((survivorBefore + edenBefore) / 1024));
newEvent.setPostUsed((int) ((survivorAfter + edenAfter) / 1024));
newEvent.setTotal((int) ((survivorCapacity + edenCapacity) / 1024));
// Old Generation
// %12: Before
// %13: After
// %14: Capacity
final long oldBefore = Long.parseLong(st.nextToken());
final long oldAfter = Long.parseLong(st.nextToken());
final long oldCapacity = Long.parseLong(st.nextToken());
GCEvent oldEvent = new GCEvent();
oldEvent.setType(AbstractGCEvent.Type.TENURED);
oldEvent.setPreUsed((int) (oldBefore / 1024));
oldEvent.setPostUsed((int) (oldAfter / 1024));
oldEvent.setTotal((int) (oldCapacity / 1024));
// Permanent Generation (Storage of Reflective Objects)
// %15: Before
// %16: After
// %17: Capacity
final long permBefore = Long.parseLong(st.nextToken());
final long permAfter = Long.parseLong(st.nextToken());
final long permCapacity = Long.parseLong(st.nextToken());
GCEvent permEvent = new GCEvent();
permEvent.setType(AbstractGCEvent.Type.PERM);
permEvent.setPreUsed((int) (permBefore / 1024));
permEvent.setPostUsed((int) (permAfter / 1024));
permEvent.setTotal((int) (permCapacity / 1024));
// %18: Time taken in seconds to finish the gc
final double pause = NumberParser.parseDouble(st.nextToken());
event.setPause(pause);
event.setPreUsed(newEvent.getPreUsed() + oldEvent.getPreUsed());
event.setPostUsed(newEvent.getPostUsed() + oldEvent.getPostUsed());
event.setTotal(newEvent.getTotal() + oldEvent.getTotal());
event.add(newEvent);
if (event.isFull()) {
event.add(oldEvent);
}
event.add(permEvent);
model.add(event);
}
return model;
} finally {
if (in != null)
try {
in.close();
} catch (IOException ioe) {
}
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading done.");
}
}
use of com.tagtraum.perf.gcviewer.model.GCEvent in project GCViewer by chewiebug.
the class DataReaderHPUX1_4_1 method read.
public GCModel read() throws IOException {
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading HP-UX 1.4.1-1.4.2 format...");
try {
final GCModel model = new GCModel();
model.setFormat(GCModel.Format.SUN_X_LOG_GC);
String line = null;
GCEvent event = null;
while ((line = in.readLine()) != null && shouldContinue()) {
final StringTokenizer st = new StringTokenizer(line, " ");
if (st.countTokens() != 22) {
if (getLogger().isLoggable(Level.WARNING)) {
getLogger().warning("Malformed line (" + in.getLineNumber() + "). Wrong number of tokens (" + st.countTokens() + "): " + line);
continue;
}
}
if (!"<GC:".equals(st.nextToken())) {
if (getLogger().isLoggable(Level.WARNING))
getLogger().warning("Malformed line (" + in.getLineNumber() + "). Expected \"<GC:\" in " + line);
continue;
}
event = new GCEvent();
/*
%1: Indicates the type of the garbage collection.
1: represents a Scavenge (GC of New Generation only)
%2: indicates if this is a parallel scavenge.
0: non-parallel scavenge
n(>0): parallel scavenge, n represents the number of
parallel GC threads
2: represents an Old Generation GC or a Full GC
%2: indicates the GC reason:
1: Allocation failure
2: Call to System.gc
3: Tenured Generation full
4: Permanent Generation full
5: Train Generation full
6: Concurrent-Mark-Sweep (CMS) Generation full
7: Old generation expanded on last scavenge
8: Old generation too full to scavenge
9: FullGCAlot
10: Allocation profiler triggered
11: Last ditch collection
If the heap area holding the reflection objects (representing classes and methods) is
full, VM first invokes permanent generation collection. If that fails, then it tries to
expand permanent generation.
If that also fails, it invokes last ditch collection, to reclaim as much space as possible.
12: Heap dump triggered
13: gcLocker triggered
14: No cause specified
(Number 11: "Last ditch collection" is added since 1.4.2.03. Number 12, 13 and 14 are added since 1.4.2.10).
3: represents a complete background CMS GC
%2: indicates the GC reason:
1: Occupancy > initiatingOccupancy
2: Expanded recently
3: Incremental collection will fail
4: Linear allocation will fail
5: Anticipated promotion
4: represents an incomplete background CMS GC
(exited after yielding to foreground GC)
%2: n.m
n indicates the GC reason:
1: Occupancy > initiatingOccupancy
2: Expanded recently
3: Incremental collection will fail
4: Linear allocation will fail
5: Anticipated promotion
m indicates the background CMS state when yielding:
0: Resetting
1: Idling
2: InitialMarking
3: Marking
4: FinalMarking
5: Precleaning
6: Sweeping
*/
final int typeOfGC = Integer.parseInt(st.nextToken());
// %2: see above
final float gcDetails = Float.parseFloat(st.nextToken());
event.setType(findType(typeOfGC, gcDetails));
// %3: Program time at the beginning of the collection, in seconds
event.setTimestamp(NumberParser.parseDouble(st.nextToken()));
// %4: Garbage collection invocation. Counts of background CMS GCs
// and other GCs are maintained separately
st.nextToken();
// %5: Size of the object allocation request that forced the GC, in bytes
st.nextToken();
// %6: Tenuring threshold - determines how long the new born object
// remains in the New Generation
st.nextToken();
// Eden Sub-space (within the New Generation)
// %7: Before
// %8: After
// %9: Capacity
final long edenBefore = Long.parseLong(st.nextToken());
final long edenAfter = Long.parseLong(st.nextToken());
final long edenCapacity = Long.parseLong(st.nextToken());
/*
GCEvent edenEvent = new GCEvent();
edenEvent.setType(AbstractGCEvent.Type.DEF_NEW);
edenEvent.setPreUsed((int)(edenBefore / 1024));
edenEvent.setPostUsed((int)(edenAfter / 1024));
edenEvent.setTotal((int)(edenCapacity / 1024));
*/
// Survivor Sub-space (within the New Generation)
// %10: Before
// %11: After
// %12: Capacity
final long survivorBefore = Long.parseLong(st.nextToken());
final long survivorAfter = Long.parseLong(st.nextToken());
final long survivorCapacity = Long.parseLong(st.nextToken());
/*
GCEvent survivorEvent = new GCEvent();
survivorEvent.setType(AbstractGCEvent.Type.DEF_NEW);
survivorEvent.setPreUsed((int)(survivorBefore / 1024));
survivorEvent.setPostUsed((int)(survivorAfter / 1024));
survivorEvent.setTotal((int)(survivorCapacity / 1024));
*/
// Since we don't distinguish between survivor spaces and eden, we add things up.
final GCEvent newEvent = new GCEvent();
newEvent.setType(AbstractGCEvent.Type.DEF_NEW);
newEvent.setPreUsed((int) ((survivorBefore + edenBefore) / 1024));
newEvent.setPostUsed((int) ((survivorAfter + edenAfter) / 1024));
newEvent.setTotal((int) ((survivorCapacity + edenCapacity) / 1024));
// Old Generation
// %13: Before
// %14: After
// %15: Capacity
final long oldBefore = Long.parseLong(st.nextToken());
final long oldAfter = Long.parseLong(st.nextToken());
final long oldCapacity = Long.parseLong(st.nextToken());
final GCEvent oldEvent = new GCEvent();
oldEvent.setType(AbstractGCEvent.Type.TENURED);
oldEvent.setPreUsed((int) (oldBefore / 1024));
oldEvent.setPostUsed((int) (oldAfter / 1024));
oldEvent.setTotal((int) (oldCapacity / 1024));
// Permanent Generation (Storage of Reflective Objects)
// %16: Before
// %17: After
// %18: Capacity
final long permBefore = Long.parseLong(st.nextToken());
final long permAfter = Long.parseLong(st.nextToken());
final long permCapacity = Long.parseLong(st.nextToken());
final GCEvent permEvent = new GCEvent();
permEvent.setType(AbstractGCEvent.Type.PERM);
permEvent.setPreUsed((int) (permBefore / 1024));
permEvent.setPostUsed((int) (permAfter / 1024));
permEvent.setTotal((int) (permCapacity / 1024));
// %19: The total stop-the-world duration, in seconds.
final double pause = NumberParser.parseDouble(st.nextToken());
event.setPause(pause);
// %20: The total time used in collection, in seconds.
// ignore for now
event.setPreUsed(newEvent.getPreUsed() + oldEvent.getPreUsed());
event.setPostUsed(newEvent.getPostUsed() + oldEvent.getPostUsed());
event.setTotal(newEvent.getTotal() + oldEvent.getTotal());
event.add(newEvent);
if (event.isFull()) {
event.add(oldEvent);
}
event.add(permEvent);
model.add(event);
}
return model;
} finally {
if (in != null)
try {
in.close();
} catch (IOException ioe) {
}
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading done.");
}
}
use of com.tagtraum.perf.gcviewer.model.GCEvent in project GCViewer by chewiebug.
the class DataReaderIBM1_3_1 method read.
public GCModel read() throws IOException {
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading IBM 1.3.1 format...");
try {
final GCModel model = new GCModel();
model.setFormat(GCModel.Format.IBM_VERBOSE_GC);
int state = 0;
String line = null;
GCEvent lastEvent = new GCEvent();
GCEvent event = null;
long basetime = 0;
cycleStartGCFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
while ((line = in.readLine()) != null && shouldContinue()) {
final String trimmedLine = line.trim();
if (!"".equals(trimmedLine) && !trimmedLine.startsWith("<GC: ") && !trimmedLine.startsWith("<")) {
System.err.println("Malformed line (" + in.getLineNumber() + "): " + line);
state = 0;
}
switch(state) {
case 0:
if (line.indexOf("Allocation Failure.") != -1) {
event = new GCEvent();
event.setType(AbstractGCEvent.Type.FULL_GC);
event.setTimestamp(lastEvent.getTimestamp() + parseTimeSinceLastAF(line));
// stay in state 0
break;
} else if (line.indexOf("GC cycle started") != -1) {
// can apparently occur without AF
event = new GCEvent();
event.setType(AbstractGCEvent.Type.FULL_GC);
final long time = parseGCCycleStart(line);
if (basetime == 0)
basetime = time;
event.setTimestamp((time - basetime) / 1000.0d);
state++;
break;
} else if (line.indexOf("managing allocation failure, action=3") != -1) {
event = new GCEvent();
event.setType(AbstractGCEvent.Type.FULL_GC);
event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
event.setPreUsed(parsePreUsedAFAction3(line));
event.setPostUsed(event.getPreUsed());
state = 2;
break;
}
break;
case 1:
if (line.indexOf("freed") != -1 && line.indexOf("unloaded") == -1) {
event.setPreUsed(parsePreUsed(line));
event.setPostUsed(parsePostUsed(line));
event.setTotal(parseTotalAfterGC(line));
event.setPause(parsePause(line));
model.add(event);
lastEvent = event;
event = null;
state = 0;
break;
}
break;
case 2:
if (line.indexOf("expanded heap by ") != -1 || line.indexOf("expanded heap fully by ") != -1) {
event.setTotal(parseTotalAfterHeapExpansion(line));
state++;
break;
}
break;
case 3:
if (line.indexOf("completed in ") != -1) {
event.setPause(parsePause(line) - lastEvent.getPause());
model.add(event);
lastEvent = event;
event = null;
state = 0;
}
break;
default:
}
}
//System.err.println(model);
return model;
} finally {
if (in != null)
try {
in.close();
} catch (IOException ioe) {
}
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Done reading.");
}
}
use of com.tagtraum.perf.gcviewer.model.GCEvent in project GCViewer by chewiebug.
the class DataReaderIBM1_4_2 method read.
public GCModel read() throws IOException {
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading IBM 1.4.2 format...");
try {
final GCModel model = new GCModel();
model.setFormat(GCModel.Format.IBM_VERBOSE_GC);
int state = 0;
String line = null;
GCEvent lastEvent = new GCEvent();
GCEvent event = null;
long basetime = 0;
cycleStartGCFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
while ((line = in.readLine()) != null && shouldContinue()) {
final String trimmedLine = line.trim();
if (!"".equals(trimmedLine) && !trimmedLine.startsWith("<GC: ") && !trimmedLine.startsWith("<")) {
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Malformed line (" + in.getLineNumber() + "): " + line);
state = 0;
}
switch(state) {
case 0:
if (line.indexOf("Allocation Failure.") != -1) {
event = new GCEvent();
event.setType(AbstractGCEvent.Type.FULL_GC);
event.setTimestamp(lastEvent.getTimestamp() + parseTimeSinceLastAF(line));
// stay in state 0
break;
} else if (line.indexOf("GC cycle started") != -1) {
// can apparently occur without AF
event = new GCEvent();
event.setType(AbstractGCEvent.Type.FULL_GC);
final long time = parseGCCycleStart(line);
if (basetime == 0)
basetime = time;
event.setTimestamp((time - basetime) / 1000.0d);
state++;
break;
} else if (line.indexOf("managing allocation failure, action=3") != -1) {
event = new GCEvent();
event.setType(AbstractGCEvent.Type.FULL_GC);
event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
event.setPreUsed(parsePreUsedAFAction3(line));
event.setPostUsed(event.getPreUsed());
// default to last event's total
event.setTotal(lastEvent.getTotal());
state = 2;
break;
}
break;
case 1:
if (line.indexOf("freed") != -1 && line.indexOf("unloaded") == -1) {
event.setPreUsed(parsePreUsed(line));
event.setPostUsed(parsePostUsed(line));
event.setTotal(parseTotalAfterGC(line));
event.setPause(parsePause(line));
model.add(event);
lastEvent = event;
event = null;
state = 0;
break;
}
break;
case 2:
if (line.indexOf("expanded heap by ") != -1 || line.indexOf("expanded heap fully by ") != -1) {
event.setTotal(parseTotalAfterHeapExpansion(line));
state++;
break;
}
if (line.indexOf("completed in") == -1)
break;
case 3:
if (line.indexOf("completed in ") != -1) {
event.setPause(parsePause(line) - lastEvent.getPause());
model.add(event);
lastEvent = event;
event = null;
state = 0;
}
break;
default:
}
}
//System.err.println(model);
return model;
} finally {
if (in != null)
try {
in.close();
} catch (IOException ioe) {
}
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Done reading.");
}
}
use of com.tagtraum.perf.gcviewer.model.GCEvent in project GCViewer by chewiebug.
the class AbstractDataReaderSun method parseDetailEventsIfExist.
/**
* Parses detail events if any exist at current <code>pos</code> in <code>line</code>.
*
* @param line current line
* @param pos current parse position
* @param event enclosing event
* @throws ParseException some problem when parsing the detail event
*/
protected void parseDetailEventsIfExist(final String line, final ParseInformation pos, final GCEvent event) throws ParseException {
int currentIndex = pos.getIndex();
boolean currentIndexHasChanged = true;
while (hasNextDetail(line, pos) && currentIndexHasChanged) {
final GCEvent detailEvent = new GCEvent();
try {
if (nextCharIsBracket(line, pos)) {
detailEvent.setDateStamp(event.getDatestamp());
detailEvent.setTimestamp(event.getTimestamp());
} else {
ZonedDateTime datestamp = parseDatestamp(line, pos);
detailEvent.setDateStamp(datestamp);
detailEvent.setTimestamp(getTimestamp(line, pos, datestamp));
}
detailEvent.setExtendedType(parseType(line, pos));
if (nextIsTimestamp(line, pos) || nextIsDatestamp(line, pos)) {
parseDetailEventsIfExist(line, pos, detailEvent);
}
if (detailEvent.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE) {
setMemoryAndPauses(detailEvent, line, pos);
} else if (detailEvent.getExtendedType().getPattern() == GcPattern.GC_MEMORY) {
setMemory(detailEvent, line, pos);
skipBlanksAndCommas(line, pos);
if (line.indexOf("]", pos.getIndex()) == pos.getIndex()) {
pos.setIndex(pos.getIndex() + 1);
}
} else {
detailEvent.setPause(parsePause(line, pos));
}
event.add(detailEvent);
} catch (UnknownGcTypeException e) {
skipUntilEndOfDetail(line, pos, e);
} catch (NumberFormatException e) {
skipUntilEndOfDetail(line, pos, e);
}
// event name -> stick them together here (they are part of the "parent" event)
if (nextIsPromotionFailed(line, pos)) {
pos.setIndex(pos.getIndex() + 2);
event.setExtendedType(extractTypeFromParsedString(event.getExtendedType() + "--"));
}
// in a line with complete garbage the parser must not get stuck; just stop parsing.
currentIndexHasChanged = currentIndex != pos.getIndex();
currentIndex = pos.getIndex();
}
}
Aggregations