<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Erik,<div class=""><br class=""></div><div class="">I wasn’t sure how committed everyone was to the ZGCPressure especially as it’s in the JEP. I also wasn’t sure about how entangled one would want the flags to be. For example, I’m guessing that a good default value for GCPressure would be 1 or 2 for the Serial collector whereas for G1 I believe Google has settled on 20 IIRC for their version of this flag. I could see 1 or 2 for the Parallel collector should it be decided that the work be performed on that collector also. But other than that, my first thought was, maybe this could just be GCPressure.</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class="">Kirk<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 24, 2024, at 6:28 AM, Erik Osterlund <<a href="mailto:erik.osterlund@oracle.com" class="">erik.osterlund@oracle.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Kirk,
<div class=""><br class="">
</div>
<div class="">I wonder if we all end up having a -XX:{Z, G1, Shenandoah, Serial, Parallel?}GCPressure=[similar, range] flag to hint to the GC to be more or less aggressive, if we should try to have just a single GCPressure flag for this instead. What do you think?</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">/Erik</div>
<div class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 23 Sep 2024, at 17:48, Kirk Pepperdine <<a href="mailto:kirk@kodewerk.com" class="">kirk@kodewerk.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<span style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);" class="">Hi,</span><span style="caret-color: rgb(0, 0, 0);" class=""></span>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div class=""><font face="Aptos, Arial, Helvetica, sans-serif" size="3" class="">I wanted to surface to the mailing list that we've taken on the task of adding Automated Heap Sizing (AHS) as has been introduced into ZGC (and is currently being introduced into G1
</font><a href="https://github.com/openjdk/jdk/pull/20783" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">https://github.com/openjdk/jdk/pull/20783</a><font face="Aptos, Arial, Helvetica, sans-serif" size="3" class="">)) into the Serial collector.
The goals of this effort are modeled after the goals for ZGC and we plan to borrow as much as possible (or as much as makes sense). For example, we would like to alter the default settings for -Xmx and -Xms. Instead of 1/4, the default MaxHeapSize would be
set to available RAM. The collector will use of memory and CPU pressure, similar to what was introduced in ZGC, to control heap expansion and contraction. Current sizing ergonomics is based on the <span style="caret-color: rgb(0, 0, 0);" class="">number</span> of non-daemon
threads. Altering this is expected to give the Serial collector a more dynamic ability to uncommit memory no longer in use (thus be more memory efficient when running in a container). The flags SoftMaxHeapSize and SerialPressure as well as the level of global
memory pressure would be used to help guide ergonomic choices. This new ergonomic choice should work to minimize GC overhead while avoiding becoming an OOM victim. As part of this, the goal is to provide enough memory but not at all costs.</font></div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">We see this work being broken down into several steps. Very roughly the steps would be;</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">- Introduce an adaptive size policy that takes into account memory and CPU pressure along with global memory pressure.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""> - Heap should be large enough to minimize GC overhead but not large enough to trigger OOM.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""> - Introduce -XX:SerialPressure=[0-100] to support this work.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""> - introduce a smoothing algorythm to avoid excessive small resizes.</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">- Introduce manageable flag SoftMaxHeapSize to define a target heap size and set the default max heap size to 100% of available.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">- Add in the ability to uncommit memory (to reduce global memory pressure).</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">While working through the details of this work I noted that there appear to opportunities to offer new defaults for other settings. For example, when tuning GC I've found that it's
best to set max heap size to the sum of the size of Eden, Survivor, and Tenured. The reasoning is that each of these spaces surves a specific purpose in managing object lifecycles and as such, (with few exceptions) each make use of a different metric to guide
how to size. Also, unlike ZGC, there is an overhead penalty for having an oversized tenured space. Consequently there is a sizing sweetspot where overhead will be minimized . Too small and overheads and GC cycle freqency will be very high. As heap is increases
past the optimal size you will tend to see a gradual degradation in GC performance.</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">For Eden the guiding metric is allocation rate. For Survivor it's life cycle (age table). For Tenured it's live set size. Using these metrics to determine size of the parts and
use that to then calculate a max heap size has almost always yielded lower GC overheads than setting a heap size and then letting ratios size everything. This maybe a separate piece of work but the intent would be to have ergonomics calculate optimal eden,
survivor and tenured sizes. Each young collection is an opportunity to resize Eden and Survivor whereas a full would be used to resize Eden, Survivor and Tenured space. This may lead to the need to ignore NewRatio and (the soft target) MaxGCPauseMillis.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">As for testing. I’m currently looking at modifying HyperAlloc to add ability to alter the shape of the load on the collector over time.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">All of this is still in it’s infancy and we’re open for guidance and input.</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">As for the work on G1, an initial patch as been submitted (URL above) and is open for comments.</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Kind regards,</div>
<div style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><span style="background-color: rgb(255, 255, 255);" class="">Kirk</span></div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div></blockquote></div><br class=""></div></body></html>