Skip to content

Commit

Permalink
Merge branch '1.9.x' into 1.10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Jan 19, 2024
2 parents dd7d657 + 3c46759 commit ebc3e8d
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ public void handleNotification(Notification notification, Object ref) {

// Some GC implementations such as G1 can reduce the old gen size as part of a
// minor GC. To track the live data size we record the value if we see a
// reduction in the long-lived
// heap size or after a major/non-generational GC. In some cases,
// longLivedAfter is 0, we ignore those notifications, see: gh-4497.
if (longLivedAfter > 0 && (longLivedAfter < longLivedBefore
|| shouldUpdateDataSizeMetrics(notificationInfo.getGcName()))) {
// reduction in the long-lived heap size or after a major/non-generational GC.
// ZGC Warmup notifications should be ignored since the long-lived heap size
// is zero there.
if ((longLivedAfter < longLivedBefore || shouldUpdateDataSizeMetrics(notificationInfo.getGcName()))
&& !isZgcWarmingUp(gcCause, longLivedAfter)) {
liveDataSize.set(longLivedAfter);
maxDataSize.set(longLivedPoolNames.stream().mapToLong(pool -> after.get(pool).getMax()).sum());
}
Expand All @@ -242,6 +242,19 @@ private void countPoolSizeDelta(Map<String, MemoryUsage> before, Map<String, Mem
}
}

/**
* Sometimes ZGC emits "Warmup" notification, where longLivedAfter is 0, we should
* ignore those notifications, see: gh-4497. This method should detect these
* cases.
* @param gcCause The action performed by the garbage collector
* @param longLivedAfter Size of the long-lived pools after collection
* @return Whether the ZGC warmup notification is emitted with zero long-lived
* pools size
*/
private boolean isZgcWarmingUp(String gcCause, long longLivedAfter) {
return longLivedAfter == 0 && "Warmup".equals(gcCause);
}

private boolean shouldUpdateDataSizeMetrics(String gcName) {
return nonGenerationalGcShouldUpdateDataSize(gcName) || isMajorGenerationalGc(gcName);
}
Expand Down

0 comments on commit ebc3e8d

Please sign in to comment.