Improve Archive Region Calculation (#211) (#369)

* 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>
This commit is contained in:
Danny Lau 2024-08-07 00:51:50 +08:00 коммит произвёл GitHub
Родитель 25a8f22bed
Коммит aaeb875c7a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -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);
@ -102,10 +103,15 @@ public abstract class G1GCPauseEvent extends G1GCEvent {
} 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);
}
}
@ -121,4 +127,7 @@ public abstract class G1GCPauseEvent extends G1GCEvent {
return this.cpuSummary;
}
public void addHeapRegionSize(int heapRegionSize) {
this.heapRegionSize = heapRegionSize;
}
}

Просмотреть файл

@ -544,6 +544,7 @@ class G1GCForwardReference extends ForwardReference {
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) {

Просмотреть файл

@ -494,6 +494,7 @@ public class UnifiedG1GCParser extends UnifiedGCLogParser implements UnifiedG1GC
forwardReference.setHumongousRegionSummary(summary);
break;
case "Archive":
// Archive Region type is only available in JDK 14 and 17.
forwardReference.setArchiveRegionSummary(summary);
break;
default: