<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=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 11, 2024, at 7:50 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="">Do I read the table right that the idea is to basically shrink when CPU saturation is low, and expand when it’s high?</div></div></div></blockquote><div><br class=""></div>Yes, this is an overly simplified table based on the reasoning that the overall GC cost is a function of GC frequency times the cost of individual collections. The cost of an individual collection is a function of scan for roots and copying or compaction costs. If I look at the levers I have to pull, I can tune the application (obviously not an option for this exercise) or I can adjust the size of Eden, Survivor and tenured. I treat all of these spaces separately as they perform different roles and will experience different pressures placed on them by different workloads. The proper table is more complex but this gets the general idea across.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">If so it’s worth keeping in mind that the high level problem I’m trying to solve is that we use a static amount of memory whether it’s needed or not. This smells like it might take a static amount of CPU (whatever we define as moderate), whether it’s needed
or not instead, as we hold a CPU magnet around whatever level is “moderate". As a Swedish GC designer, I think it’s important to also teach the heuristics the notion of lagom (cf. <a href="https://en.wikipedia.org/wiki/Lagom" class="">https://en.wikipedia.org/wiki/Lagom</a>),
to prevent a process that could have gotten away with using 1% CPU from ending up using, say, 50% CPU, just so it could shrink the last couple of bytes of heap, when memory maybe wasn’t really a problem at all in the first place.</div></div></div></blockquote><div><br class=""></div>There will have to be a dampener of some sort to says.. close enough.<br class=""><blockquote type="cite" class=""><div class=""><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class=""><br class="">
</div>
<div class="">Another thing worth thinking about when changing the heap size in a GC like Serial, is that changing the heap size will change the size of the generations, and hence we probably need to teach Serial how to move the boundaries between the young and old
generations. I suspect that will be an interesting experience. Just a heads up!</div></div></div></blockquote><div><br class=""></div>I don’t think this needs to happen. There appears to be a separate reserved space for Young and Tenured. At any rate, I always treat the internal spaces separately and them sum them up to determine a max heap size.</div><div><br class=""></div><div>The one case of interest is low allocation pressure, high GC overhead. To me this suggests that Tenured occupancy is approaching the full mark. Expanding tenured will not lower the cost of an individual collection but it will decrease frequency. If this is the case, how does one calculate GC overhead? IOWs, how big is the window going back in time. Maybe I use a 1, 5, and 15 minute window and make use of the trending information? I will start experimenting soon.</div><div><br class=""></div><div>Kind regards,</div><div>Kirk</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">/Erik<br id="lineBreakAtBeginningOfMessage" class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 4 Jun 2024, at 21:18, 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="">
Hi Erik,
<div class=""><br class="">
</div>
<div class="">Thanks for the link. This all reads very nicely all but your favorite line because involves Pi because we all know cake is square and Pi is round.</div>
<div class=""><br class="">
</div>
<div class="">The current ergonomic sizing for the serial collector is a function of the number of non-Daemon threads. I don’t think that the serial collector needs logic as complex as what you’ve put in play here. I think I can get away with a simple GC overhead calculation.
I based that assessment on the following chart.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<table cellspacing="0" cellpadding="0" style="border-collapse: collapse" class="">
<tbody class="">
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; background-color: #b0b3b2; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class=""><b class="">Allocation Pressure </b></font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; background-color: #b0b3b2; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class=""><b class="">CPU Saturation</b></font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; background-color: #b0b3b2; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class=""><b class="">Action</b></font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 12.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Low</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 12.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Low</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 12.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Shrink</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Moderate</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Low</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Shrink</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">High</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Low</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Shrink</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Low</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Moderate</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">None</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Moderate</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Moderate</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">None</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">High</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Moderate</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">None</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Low</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">High</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Expand</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Moderate</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">High</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Expand</font></div>
</td>
</tr>
<tr class="">
<td valign="top" style="width: 104.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">High</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">High</font></div>
</td>
<td valign="top" style="width: 89.0px; height: 11.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #000000 #000000 #000000 #000000; padding: 4.0px 4.0px 4.0px 4.0px" class="">
<div style="margin: 0px;" class=""><font face="Helvetica Neue" style="font-stretch: normal; font-size: 10px; line-height: normal; font-family: "Helvetica Neue"; font-variant-ligatures: common-ligatures;" class="">Expand</font></div>
</td>
</tr>
</tbody>
</table>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">If we take GC overhead ~= CPU saturation, then this chart implies that setting a GC throughput target and then resizing Java heap as needed to meet that target is all that is needed. I intend to experiment with this logic to start with.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">Kirk</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On May 29, 2024, at 5:10 PM, Erik Osterlund <<a href="mailto:erik.osterlund@oracle.com" class="">erik.osterlund@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div 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 have a prototype here if you are interested in having a peek at what I’m cooking: <a href="https://urldefense.com/v3/__https://github.com/fisk/jdk/tree/zgc_auto_heap_v3__;!!ACWV5N9M2RV99hQ!MMvDR8LjE_cUChZ5ItpFCN28jqvepjpCHTuLf0jItSDsfKIflro8v5R5EDU0NDS7Dzu3PljSi2ORA3dzKw$" class="">https://github.com/fisk/jdk/tree/zgc_auto_heap_v3</a></div>
<div class=""><br class="">
</div>
<div class="">I have some additional things I would like to try out, but it’s starting to shape up pretty well I think.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">The exponential backoff logic is here: <a href="https://urldefense.com/v3/__https://github.com/fisk/jdk/blob/22ca93998b7018394338b07f51659815faf69bfa/src/hotspot/share/gc/z/zAdaptiveHeap.cpp*L191__;Iw!!ACWV5N9M2RV99hQ!MMvDR8LjE_cUChZ5ItpFCN28jqvepjpCHTuLf0jItSDsfKIflro8v5R5EDU0NDS7Dzu3PljSi2O2oChJXQ$" class="">https://github.com/fisk/jdk/blob/22ca93998b7018394338b07f51659815faf69bfa/src/hotspot/share/gc/z/zAdaptiveHeap.cpp#L191</a></div>
<div class="">The best line in the entire patch is here: <a href="https://urldefense.com/v3/__https://github.com/fisk/jdk/blob/22ca93998b7018394338b07f51659815faf69bfa/src/hotspot/share/gc/z/zAdaptiveHeap.cpp*L101__;Iw!!ACWV5N9M2RV99hQ!MMvDR8LjE_cUChZ5ItpFCN28jqvepjpCHTuLf0jItSDsfKIflro8v5R5EDU0NDS7Dzu3PljSi2O_WeqjBA$" class="">https://github.com/fisk/jdk/blob/22ca93998b7018394338b07f51659815faf69bfa/src/hotspot/share/gc/z/zAdaptiveHeap.cpp#L101</a></div>
<div class=""><br class="">
</div>
<div class="">When it comes to reducing footprint for a memory-idle app, ZGC has an uncommitter thread that that uncommits memory regions when they “time out”. Basically, if you haven’t used a region for X amount of time, then it will get uncommitted. Normally this
X is 5 minutes. However, I scale this timeout by the reciprocal of the memory pressure in this patch, which is continuously monitored. A consequence of that is that when memory gets increasingly scarce, we will start desperately dumping all memory we can get
rid of, which will cause the heap to shrink, and GC to kick in which can lead to more opportunities of shrinking further, should the situation be desperate.</div>
<div class=""><br class="">
</div>
<div class="">Anyway, hope you enjoy the reading!</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">/Erik</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 29 May 2024, at 16:03, 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="">
Hi Erik,
<div class=""><br class="">
</div>
<div class="">I’ve started looking at the serial collector and I’m interested in experimenting with the exponential function also. I’d also like to add a part where a memory-idle app could reduce it’s memory footprint. That said, to achieve this I think one will need
a speculative full and I’m not so happy about introducing yet another speculative collection tactic given that all past attempts to do good speculatively have not ended well.</div>
<div class=""><br class="">
</div>
<div class="">I look forward to looking at your code.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">Kirk</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On May 28, 2024, at 7:07 PM, Erik Osterlund <<a href="mailto:erik.osterlund@oracle.com" class="">erik.osterlund@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="auto" class="">
<div dir="ltr" class=""></div>
<div dir="ltr" class="">Hi Kirk,</div>
<div dir="ltr" class=""><br class="">
</div>
<div dir="ltr" class="">Yeah, I think the approach itself should work well for Serial and Parallel as well for the most part. I personally welcome any work on this in the context of Serial and Parallel, if your team would like to have a look at that.</div>
<div dir="ltr" class=""><br class="">
</div>
<div dir="ltr" class="">Kind regards,</div>
<div dir="ltr" class="">/Erik</div>
<div dir="ltr" class=""><br class="">
<blockquote type="cite" class="">On 16 May 2024, at 17:19, Kirk Pepperdine <<a href="mailto:kirk@kodewerk.com" class="">kirk@kodewerk.com</a>> wrote:<br class="">
<br class="">
</blockquote>
</div>
<blockquote type="cite" class="">
<div dir="ltr" class=""> Hi Erik,
<div class=""><br class="">
</div>
<div class="">I’m glad this worked. I’d like to see a solution that works across all collectors. We’re looking to experiment with the serial/parallel collector for the cases when applications will be running in smaller containers where these collectors are a more suitable
choice.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">Kirk</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On May 13, 2024, at 5:54 PM, Erik Osterlund <<a href="mailto:erik.osterlund@oracle.com" class="">erik.osterlund@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div 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 experimented with taking aside a small portion of the machine memory, and say it is “critical”. The GC pressure is then scaled by an exponential function over what fraction of the critical memory reserve is used on the machine. Unless memory pressure
on the machine is very high, it changes nothing in the behaviour. But as it gets critically high, it makes the GC try a lot harder as we run out of memory, and at the same time gives all processes a unified view of what the pressure is, and you get into an
equilibrium situation where all processes apply similar GC pressure to avoid running out of memory. I also scale the delay for uncommitting memory by said memory pressure which causes us to uncommit memory increasingly aggressively, as memory levels get increasingly
critical.</div>
<div class=""><br class="">
</div>
<div class="">Of course, you can always allocate something that uses exactly the amount of memory that is left on the machine, and you will have a problem because we don’t have enough time to shrink. But in practice it seems to reduce the amount of trouble due to coordination
with other processes significantly. I have run both homogeneous and heterogeneous experiments that normally just should absolutely not work, that works deterministically fine with this mechanism. I think it’s worth adding this mechanism to the scope of the
JEP, to further reduce the probability that users need to mess with heap sizing. So thanks for the suggestion to have a look at this.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">/Erik<br id="lineBreakAtBeginningOfMessage" class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 3 May 2024, at 15:25, Erik Osterlund <<a href="mailto:erik.osterlund@oracle.com" class="">erik.osterlund@oracle.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Kirk,<br id="lineBreakAtBeginningOfMessage" class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 2 May 2024, at 18:59, 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="">
Hi Erik,
<div class=""><br class="">
</div>
<div class="">Some questions.<br class="">
<div class=""><br class="">
</div>
<div class="">On the question of allocation stalls, couldn’t/shouldn’t one just start the collection cycles sooner?</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Yes - if nothing unexpected happens, then we will indeed just start earlier. But when unpredicted things happen, such as large unpredicted surges in allocation rate, or sudden increase in residency compared to earlier collections, there is always a risk
of stalling. Just taking some extra memory is typically preferred, instead of stalling.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">
<div class="">On the question of sharing in containers, I’m aware of two different experiments on how to resolve the issue of allowing Java heap to consume more of available memory. Of the two the most interesting is a modification of G1 that uses GC thread CPU overhead
as a signal to decide if Java heap should be expanded or contracted. The idea is to keep GC thread utilization within a band (of ~20%). The other component of this experiment is to fail any attempts to expand should that expansion risk triggering an OOM killer.
In this case the failed expansion will result in a hotter CPU. That said, this a significantly more graceful degredation than having the process terminated. My question is, would you consider taking a similar approach for ZGC?</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">The first part of it sounds indeed quite similar to what I’m planning.</div>
<div class=""><br class="">
</div>
<div class="">Regarding reacting to some “dangerously high” watermark, I have thought a bit about that, and have so far decided to stay out of it. Mostly because I haven’t thought of any promising way of doing that without getting strange echo effects where multiple
JVMs are shrinking and expanding continuously based on reactions, and reactions to said reactions, rather than a carefully planned global plan from an external source controlling them.</div>
<div class=""><br class="">
</div>
<div class="">What might work reasonably well though, is to compute the GC pressure if it hasn’t been specified, to something like 1.0 / MIN(0.2, memory_left_fraction). This way, the GC pressure is “medium” until you get to the last 20% of memory, and then increases
proportionally, as the last 20% memory on the machine starts getting used up. The nice thing with such an approach, is that all JVMs agree about the GC pressure, and will do their fair share extra work to keep it down, without oscillating up and down or having
a single escape goat JVM that takes all the burden. I’ll try that and see if that can work well.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">
<div class="">Finally, on the flag ZGCPressure, could you speak a little more about how it balances CPU vs memory? Specifically, what does the value 5 represent? I understand if one were to pull on that lever you affect the level of aggressiveness but is this aggressiveness
of how quickly heap would be expanded?</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">I have intentionally been a bit vague here, as I am hoping to be able to change the implementation over time without being tied down to a specific contract that becomes impossible to conform to in the future where this functionality becomes more complex.</div>
<div class="">Having said that, 5 is a sort of medium level of aggressiveness. Considering CPU utilization alone, if a process is utilizing 100% of the available CPU resources on a machine, then it will use approximately 1/8 of the available CPU, for doing GC. But it
will still perform GC less aggressively, if the frequency seems too high.</div>
<div class=""><br class="">
</div>
<div class="">Kind regards,</div>
<div class="">/Erik</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">
<div class="">Kind regards,</div>
<div class="">Kirk</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On May 2, 2024, at 7:44 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="">
<div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi,
<div class=""><br class="">
</div>
<div class="">I have written a draft JEP for a automatic heap sizing when using ZGC.</div>
<div class="">JEP description is available here: <a href="https://bugs.openjdk.org/browse/JDK-8329758" class="">https://bugs.openjdk.org/browse/JDK-8329758</a></div>
<div class=""><br class="">
</div>
<div class="">Comments and feedback are welcome.</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">/Erik</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div></blockquote></div><br class=""></body></html>