Skip to content

Commit

Permalink
Merge branch '1.10.x' into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Jan 19, 2024
2 parents 6675a12 + ebc3e8d commit f479c5e
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,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(gcName))) {
// 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(gcName))
&& !isZgcWarmingUp(gcCause, longLivedAfter)) {
liveDataSize.set(longLivedAfter);
maxDataSize.set(longLivedPoolNames.stream().mapToLong(pool -> after.get(pool).getMax()).sum());
}
Expand All @@ -252,6 +253,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 f479c5e

Please sign in to comment.