Skip to content

Commit 54e339e

Browse files
authored
Report ZGC individual collections instead of cycles (#445) (#447)
* Report ZGC individual collections instead of cycles Previously, the ZGC parser would attempt to construct a single event for each minor/major cycle, with each minor cycle containing a single young collection, and each major cycle containing a single young and a single old collection. This created a few problems. First, the implementation of the parser assumed that only one cycle could be active at any given time. As a result, any time a minor cycle started before the previous major cycle was finished, all data collected about the major cycle would be lost. Second, the data model for a MajorZGCCycle assumed there could be only one young collection per cycle. This is not the case. There can be (and frequently are) multiple young collections in a major cycle. Even if the implementation and datamodel were fixed to account for the concurrent nature of generational ZGC, grouping collections by cycle would still create API usability problems. Individual collections within a cycle independently report various JVM/heap level metrics at specific points in time. Within a single major cycle, those points in time may be very far apart, and overlap with a large number of minor cycles. If an end user wished to construct a timeline for a particular metric (for example, heap occupancy), they would need to traverse all the reported cycles, extract the metrics from the individual collections, and put them in order. To address the above issues, the parser and data models are refactored to report each individual collection (young, old, or full) immediately once they are completed instead of waiting until the parent cycle is done. The parser maintains 3 independent forward references (one for each collection type: old, young, and full). As a result, the parser will not lose state even when lines from an old collection are intermixed with lines from a young collection. * Fix mismatched GC type label * Rename ZGCCollectionType -> ZGCCycleType * Fix inconsistent whitespace * Use explicit imports in ZGCParserTest
1 parent b59f458 commit 54e339e

File tree

23 files changed

+602
-809
lines changed

23 files changed

+602
-809
lines changed

IT/src/main/java/com/microsoft/gctoolkit/integration/aggregation/CollectionCycleCountsAggregator.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import com.microsoft.gctoolkit.event.g1gc.G1GCPauseEvent;
88
import com.microsoft.gctoolkit.event.generational.GenerationalGCPauseEvent;
99
import com.microsoft.gctoolkit.event.shenandoah.ShenandoahCycle;
10-
import com.microsoft.gctoolkit.event.zgc.FullZGCCycle;
11-
import com.microsoft.gctoolkit.event.zgc.MajorZGCCycle;
12-
import com.microsoft.gctoolkit.event.zgc.MinorZGCCycle;
10+
import com.microsoft.gctoolkit.event.zgc.ZGCFullCollection;
11+
import com.microsoft.gctoolkit.event.zgc.ZGCYoungCollection;
12+
import com.microsoft.gctoolkit.event.zgc.ZGCOldCollection;
1313

1414
@Aggregates({EventSource.G1GC,EventSource.GENERATIONAL,EventSource.ZGC,EventSource.SHENANDOAH})
1515
public class CollectionCycleCountsAggregator extends Aggregator<CollectionCycleCountsAggregation> {
@@ -19,21 +19,21 @@ public CollectionCycleCountsAggregator(CollectionCycleCountsAggregation results)
1919
register(GenerationalGCPauseEvent.class, this::count);
2020
register(G1GCPauseEvent.class, this::count);
2121
register(G1GCConcurrentEvent.class, this::count);
22-
register(FullZGCCycle.class,this::count);
23-
register(MajorZGCCycle.class,this::count);
24-
register(MinorZGCCycle.class,this::count);
22+
register(ZGCFullCollection.class, this::count);
23+
register(ZGCOldCollection.class, this::count);
24+
register(ZGCYoungCollection.class, this::count);
2525
register(ShenandoahCycle.class,this::count);
2626
}
2727

28-
private void count(FullZGCCycle event) {
28+
private void count(ZGCFullCollection event) {
2929
aggregation().count(event.getGarbageCollectionType());
3030
}
3131

32-
private void count(MajorZGCCycle event) {
32+
private void count(ZGCOldCollection event) {
3333
aggregation().count(event.getGarbageCollectionType());
3434
}
3535

36-
private void count(MinorZGCCycle event) {
36+
private void count(ZGCYoungCollection event) {
3737
aggregation().count(event.getGarbageCollectionType());
3838
}
3939

IT/src/main/java/com/microsoft/gctoolkit/integration/aggregation/HeapOccupancyAfterCollectionAggregator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import com.microsoft.gctoolkit.event.g1gc.G1GCPauseEvent;
77
import com.microsoft.gctoolkit.event.generational.GenerationalGCPauseEvent;
88
import com.microsoft.gctoolkit.event.shenandoah.ShenandoahCycle;
9-
import com.microsoft.gctoolkit.event.zgc.FullZGCCycle;
10-
import com.microsoft.gctoolkit.event.zgc.MajorZGCCycle;
11-
import com.microsoft.gctoolkit.event.zgc.MinorZGCCycle;
9+
import com.microsoft.gctoolkit.event.zgc.ZGCFullCollection;
10+
import com.microsoft.gctoolkit.event.zgc.ZGCOldCollection;
11+
import com.microsoft.gctoolkit.event.zgc.ZGCYoungCollection;
1212

1313
@Aggregates({EventSource.G1GC,EventSource.GENERATIONAL,EventSource.ZGC,EventSource.SHENANDOAH})
1414
public class HeapOccupancyAfterCollectionAggregator extends Aggregator<HeapOccupancyAfterCollectionAggregation> {
@@ -17,17 +17,17 @@ public HeapOccupancyAfterCollectionAggregator(HeapOccupancyAfterCollectionAggreg
1717
super(results);
1818
register(GenerationalGCPauseEvent.class, this::extractHeapOccupancy);
1919
register(G1GCPauseEvent.class, this::extractHeapOccupancy);
20-
register(FullZGCCycle.class,this::extractHeapOccupancy);
21-
register(MajorZGCCycle.class,this::extractHeapOccupancy);
22-
register(MinorZGCCycle.class,this::extractHeapOccupancy);
20+
register(ZGCFullCollection.class, this::extractHeapOccupancy);
21+
register(ZGCOldCollection.class, this::extractHeapOccupancy);
22+
register(ZGCYoungCollection.class, this::extractHeapOccupancy);
2323
register(ShenandoahCycle.class,this::extractHeapOccupancy);
2424
}
2525

26-
private void extractHeapOccupancy(MinorZGCCycle event) {
27-
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getYoungCycle().getMemorySummary().getOccupancyAfter());
26+
private void extractHeapOccupancy(ZGCYoungCollection event) {
27+
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getMemorySummary().getOccupancyAfter());
2828
}
2929

30-
private void extractHeapOccupancy(MajorZGCCycle event) {
30+
private void extractHeapOccupancy(ZGCOldCollection event) {
3131
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getMemorySummary().getOccupancyAfter());
3232
}
3333

@@ -41,7 +41,7 @@ private void extractHeapOccupancy(G1GCPauseEvent event) {
4141
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getHeap().getOccupancyAfterCollection());
4242
}
4343

44-
private void extractHeapOccupancy(FullZGCCycle event) {
44+
private void extractHeapOccupancy(ZGCFullCollection event) {
4545
aggregation().addDataPoint(event.getGarbageCollectionType(), event.getDateTimeStamp(), event.getMemorySummary().getOccupancyAfter());
4646
}
4747

api/src/main/java/com/microsoft/gctoolkit/event/GarbageCollectionTypes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ public enum GarbageCollectionTypes implements LabelledGCEventType {
5656
G1Trap("G1GC Trap"),
5757
Unknown("Unknown"),
5858
ZGCFull("ZGC FULL"),
59-
ZGCMajor("ZGC Major"),
60-
ZGCMinor("ZGC Minor"),
59+
ZGCMajorOld("ZGC Major Old"),
60+
ZGCMajorYoung("ZGC Major Young"),
61+
ZGCMinorYoung("ZGC Minor Young"),
6162
Shenandoah("Shenandoah");
6263

6364
private final String label;

0 commit comments

Comments
 (0)