Request for Feedback and Testing on G1 Heap Resizing Prototype

Ivan Walulya ivan.walulya at oracle.com
Tue Apr 29 10:46:35 UTC 2025


As part of our preparations for AHS, we are prototyping changes to the G1 heap resizing policy to improve the effectiveness of the GCTimeRatio [1]. The GCTimeRatio is set to manage the balance between GC time and Application execution time. G1's current implementation of GCTimeRatio appears to have drifted from its intended purpose over time. It may no longer accurately guide heap sizing in response to GC overhead. Therefore, we need to change this mechanism with the goal that G1 better manages heap sizes without the need for additional tuning knobs.

The prototype allows both expansion and shrinking of the heap at the end of any GC, as opposed to the current behavior where shrinking is only allowed at Remark or Full GC pauses [2].  We also increase the default GCTimeRatio from 12 to 24 [3] (we are choosing 24 but open to suggestions). The existing default causes the heap to shrink too aggressively under the new policy in order to maintain the target GCTimeRatio. A higher default provides a better balance and avoids shrinking heap.

Additionally, we are removing the heap resizing at the end of the Remark pause which was based on MinHeapFreeRatio and MaxHeapFreeRatio. This resizing of the heap ignores current application behaviour and may lead to pathological cases of repeated concurrent mark cycles:


  *        we shrink the heap at remark,
  *        a smaller heap triggers a concurrent marking in the subsequent GCs as well as expanding the heap
  *        the concurrent cycle ends in another remark pause where the cycle restarts.

We keep this MinHeapFreeRatio-MaxHeapFreeRatio based resizing logic at the end of Full GC.

As a result of these changes, applications may settle at more appropriate and in some cases smaller heap sizes for a given GCTimeRatio. While this may show as regression in some benchmarks that are sensitive to heap size, it is still improved control over GC behaviour.

We are requesting for feedback or testing of these changes before propose to merge them with mainline.

Some of the changes that are independent of the GCTimeRatio are already out for review [4, 5], other minor fixes will be split out and pushed independently.

// Ivan

References:

[1] https://github.com/openjdk/jdk/compare/master...walulyai:jdk:G1HeapResizePolicy

[2] JDK-8238687 Investigate memory uncommit during young collections in G1 [https://bugs.openjdk.org/browse/JDK-8238687]

[3] JDK-8247843 Reconsider G1 default GCTimeRatio value [https://bugs.openjdk.org/browse/JDK-8247843]

[4] JDK-8355681 G1HeapRegionManager::find_contiguous_allow_expand ignores free regions when checking regions available for allocation [https://bugs.openjdk.org/browse/JDK-8355681]

[5] JDK-8355756 G1HeapSizingPolicy::full_collection_resize_amount should consider allocation size [https://bugs.openjdk.org/browse/JDK-8355756]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20250429/fa008af4/attachment.htm>


More information about the hotspot-gc-dev mailing list