Skip to content

Commit

Permalink
Improve Archive Region Calculation (#211) (#369)
Browse files Browse the repository at this point in the history
* improve archive region calculation (#211)

* Add comment for Archive Region availability

* Update parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java

* Update parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java

* Update parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java

* Update parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java

---------

Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>
  • Loading branch information
kkdlau and karianna authored Aug 6, 2024
1 parent 25a8f22 commit aaeb875
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class G1GCPauseEvent extends G1GCEvent {
private RegionSummary archiveRegion;

private CPUSummary cpuSummary;
private int heapRegionSize;

public G1GCPauseEvent(DateTimeStamp timeStamp, GarbageCollectionTypes type, GCCause cause, double duration) {
super(timeStamp, type, cause, duration);
Expand Down Expand Up @@ -102,10 +103,15 @@ public MemoryPoolSummary getTenured() {
} else if (getSurvivor() == null) {
return getHeap().minus(getEden());
} else {
return new MemoryPoolSummary(getHeap().getOccupancyBeforeCollection() - this.getEden().getOccupancyBeforeCollection() - getSurvivor().getOccupancyBeforeCollection(),
getHeap().getSizeBeforeCollection() - getEden().getSizeBeforeCollection() - getSurvivor().getOccupancyBeforeCollection(),
getHeap().getOccupancyAfterCollection() - getEden().getOccupancyAfterCollection() - getSurvivor().getOccupancyAfterCollection(),
getHeap().getSizeAfterCollection() - getEden().getSizeAfterCollection() - getSurvivor().getOccupancyAfterCollection());
final RegionSummary summary = getArchiveRegionSummary();
final long archiveRegionByteBefore = summary.getBefore() * heapRegionSize * 1024L;
final long archiveRegionByteAfter = summary.getAfter() * heapRegionSize * 1024L;
final long archiveRegionByteAssigned = summary.getAssigned() * heapRegionSize * 1024L;

return new MemoryPoolSummary(getHeap().getOccupancyBeforeCollection() - this.getEden().getOccupancyBeforeCollection() - getSurvivor().getOccupancyBeforeCollection() - archiveRegionByteAssigned,
getHeap().getSizeBeforeCollection() - getEden().getSizeBeforeCollection() - getSurvivor().getOccupancyBeforeCollection() - archiveRegionByteBefore,
getHeap().getOccupancyAfterCollection() - getEden().getOccupancyAfterCollection() - getSurvivor().getOccupancyAfterCollection() - archiveRegionByteAssigned,
getHeap().getSizeAfterCollection() - getEden().getSizeAfterCollection() - getSurvivor().getOccupancyAfterCollection() - archiveRegionByteAfter);
}
}

Expand All @@ -121,4 +127,7 @@ public CPUSummary getCpuSummary() {
return this.cpuSummary;
}

public void addHeapRegionSize(int heapRegionSize) {
this.heapRegionSize = heapRegionSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ private void fillInMemoryPoolStats(G1GCPauseEvent collection) {
SurvivorMemoryPoolSummary survivor = getSurvivorMemoryPoolSummary();
MemoryPoolSummary tenured = getMemoryPoolSummary(OLD_OCCUPANCY_BEFORE_COLLECTION);
MemoryPoolSummary humongous = getMemoryPoolSummary(HUMONGOUS_OCCUPANCY_BEFORE_COLLECTION);
collection.addHeapRegionSize(heapRegionSize);
if (heap != null && eden != null && survivor != null) {
collection.addMemorySummary(eden, survivor, heap);
} else if (eden == null && survivor == null && heap != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public void regionSummary(GCLogTrace trace, String line) {
forwardReference.setHumongousRegionSummary(summary);
break;
case "Archive":
// Archive Region type is only available in JDK 14 and 17.
forwardReference.setArchiveRegionSummary(summary);
break;
default:
Expand Down

0 comments on commit aaeb875

Please sign in to comment.