Skip to content

Commit

Permalink
refactor: add marker major and minor classes for ZGC cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
kcpeppe committed Jul 4, 2024
1 parent d661f31 commit 1708c0c
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.microsoft.gctoolkit.event.g1gc.G1GCPauseEvent;
import com.microsoft.gctoolkit.event.generational.GenerationalGCPauseEvent;
import com.microsoft.gctoolkit.event.shenandoah.ShenandoahCycle;
import com.microsoft.gctoolkit.event.zgc.ZGCCycle;
import com.microsoft.gctoolkit.event.zgc.MajorZGCCycle;

@Aggregates({EventSource.G1GC,EventSource.GENERATIONAL,EventSource.ZGC,EventSource.SHENANDOAH})
public class CollectionCycleCountsAggregator extends Aggregator<CollectionCycleCountsAggregation> {
Expand All @@ -17,11 +17,11 @@ public CollectionCycleCountsAggregator(CollectionCycleCountsAggregation results)
register(GenerationalGCPauseEvent.class, this::count);
register(G1GCPauseEvent.class, this::count);
register(G1GCConcurrentEvent.class, this::count);
register(ZGCCycle.class,this::count);
register(MajorZGCCycle.class,this::count);
register(ShenandoahCycle.class,this::count);
}

private void count(ZGCCycle event) {
private void count(MajorZGCCycle event) {
aggregation().count(event.getGarbageCollectionType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.microsoft.gctoolkit.event.g1gc.G1GCPauseEvent;
import com.microsoft.gctoolkit.event.generational.GenerationalGCPauseEvent;
import com.microsoft.gctoolkit.event.shenandoah.ShenandoahCycle;
import com.microsoft.gctoolkit.event.zgc.ZGCCycle;
import com.microsoft.gctoolkit.event.zgc.MajorZGCCycle;

@Aggregates({EventSource.G1GC,EventSource.GENERATIONAL,EventSource.ZGC,EventSource.SHENANDOAH})
public class HeapOccupancyAfterCollectionAggregator extends Aggregator<HeapOccupancyAfterCollectionAggregation> {
Expand All @@ -15,7 +15,7 @@ public HeapOccupancyAfterCollectionAggregator(HeapOccupancyAfterCollectionAggreg
super(results);
register(GenerationalGCPauseEvent.class, this::extractHeapOccupancy);
register(G1GCPauseEvent.class, this::extractHeapOccupancy);
register(ZGCCycle.class,this::extractHeapOccupancy);
register(MajorZGCCycle.class,this::extractHeapOccupancy);
register(ShenandoahCycle.class,this::extractHeapOccupancy);
}

Expand All @@ -29,7 +29,7 @@ private void extractHeapOccupancy(G1GCPauseEvent event) {
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getHeap().getOccupancyAfterCollection());
}

private void extractHeapOccupancy(ZGCCycle event) {
private void extractHeapOccupancy(MajorZGCCycle event) {
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getLive().getReclaimEnd());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package com.microsoft.gctoolkit.event.zgc;

import com.microsoft.gctoolkit.event.GCCause;
import com.microsoft.gctoolkit.event.GarbageCollectionTypes;
import com.microsoft.gctoolkit.time.DateTimeStamp;

public class MajorZGCCycle extends ZGCCycle {
public MajorZGCCycle(DateTimeStamp timeStamp, GarbageCollectionTypes gcType, GCCause cause, double duration) {
super(timeStamp, gcType, cause, duration);
}

public MajorZGCCycle(DateTimeStamp timeStamp, double duration) {
super(timeStamp, duration);
}

public MajorZGCCycle(DateTimeStamp timeStamp, GCCause cause, double duration) {
super(timeStamp, cause, duration);
}

public MajorZGCCycle(DateTimeStamp timeStamp, GarbageCollectionTypes gcType, double duration) {
super(timeStamp, gcType, duration);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package com.microsoft.gctoolkit.event.zgc;

import com.microsoft.gctoolkit.event.GCCause;
import com.microsoft.gctoolkit.event.GarbageCollectionTypes;
import com.microsoft.gctoolkit.time.DateTimeStamp;

public class MinorZGCCycle extends MajorZGCCycle {
public MinorZGCCycle(DateTimeStamp timeStamp, GarbageCollectionTypes gcType, GCCause cause, double duration) {
super(timeStamp, gcType, cause, duration);
}

public MinorZGCCycle(DateTimeStamp timeStamp, double duration) {
super(timeStamp, duration);
}

public MinorZGCCycle(DateTimeStamp timeStamp, GCCause cause, double duration) {
super(timeStamp, cause, duration);
}

public MinorZGCCycle(DateTimeStamp timeStamp, GarbageCollectionTypes gcType, double duration) {
super(timeStamp, gcType, duration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface GenericTokens {
String INTEGER = "\\d+";
String REAL_NUMBER = INTEGER + DECIMAL_POINT + INTEGER;
String PERCENTAGE = "(" + REAL_NUMBER + ")" + "\\s?%";
String INT_PERCENTAGE = "(" + INTEGER + ")" + "%";
String HEX = "0x[0-9,a-f]{16}";
String INT = "(" + INTEGER + ")";
String COUNTER = INT;
Expand All @@ -19,6 +20,7 @@ public interface GenericTokens {
//Time
String TIME = "(-?" + REAL_NUMBER + ")";
String DURATION_MS = TIME + "\\s?ms";
String INT_DURATION_MS = INTEGER + "ms";
//0.0700188
String PAUSE_TIME = TIME + "\\s?(?:secs?|ms)";
String CONCURRENT_TIME = PAUSE_TIME;
Expand Down
21 changes: 18 additions & 3 deletions parser/src/main/java/com/microsoft/gctoolkit/parser/ZGCParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import com.microsoft.gctoolkit.event.jvm.JVMTermination;
import com.microsoft.gctoolkit.event.zgc.OccupancySummary;
import com.microsoft.gctoolkit.event.zgc.ReclaimSummary;
import com.microsoft.gctoolkit.event.zgc.ZGCCycle;
import com.microsoft.gctoolkit.event.zgc.MajorZGCCycle;
import com.microsoft.gctoolkit.event.zgc.MinorZGCCycle;
import com.microsoft.gctoolkit.event.zgc.ZGCMemoryPoolSummary;
import com.microsoft.gctoolkit.event.zgc.ZGCMetaspaceSummary;
import com.microsoft.gctoolkit.jvm.Diary;
Expand Down Expand Up @@ -352,8 +353,22 @@ public ZGCForwardReference(DateTimeStamp dateTimeStamp, long gcId, GCCause cause
gcCause = cause;
}

ZGCCycle toZGCCycle(DateTimeStamp endTime) {
ZGCCycle cycle = new ZGCCycle(startTimeStamp, GarbageCollectionTypes.ZGCCycle, gcCause, endTime.minus(startTimeStamp));
MajorZGCCycle toZGCCycle(DateTimeStamp endTime) {

MajorZGCCycle cycle = null;
switch(forwardReference.memoryScope) {
case ALL:
cycle = new MajorZGCCycle(startTimeStamp, GarbageCollectionTypes.ZGCCycle, gcCause, endTime.minus(startTimeStamp));
break;
case YOUNG_GENERATION:
cycle = new MinorZGCCycle(startTimeStamp, GarbageCollectionTypes.ZGCCycle, gcCause, endTime.minus(startTimeStamp));
break;
case OLD_GENERATION:
cycle = new MajorZGCCycle(startTimeStamp, GarbageCollectionTypes.ZGCCycle, gcCause, endTime.minus(startTimeStamp));
break;
default:
LOGGER.warning("Internal Error - Unknown memory scope: " + forwardReference.memoryScope);
};
cycle.setGcId(gcId);
cycle.setPauseMarkStart(pauseMarkStart, pauseMarkStartDuration);
cycle.setConcurrentMark(concurrentMarkStart, concurrentMarkDuration);
Expand Down
Loading

0 comments on commit 1708c0c

Please sign in to comment.