<html><head></head><body><div><div>Hi,</div><div><br></div><div> so I started to fill out the JEP body template for the first of the improvements.</div><div>Could you help completing this as we are waiting for the OCAs? Also a second</div><div>mail thread with the second suggestion, which is probably simpler to do should</div><div>be started.</div><div><br></div><div>Timely Reducing Unused Committed Memory</div><div><br></div><div>(from <a href="http://openjdk.java.net/jeps/2">http://openjdk.java.net/jeps/2</a>)</div><div><br></div><div>//</div><div>// JDK Enhancement Proposal ("JEP") body template, v2.0</div><div>//</div><div>// ==> Delete all lines starting with "//"</div><div>// before entering a proposal into JBS</div><div>//</div><div>// Instances of this template are meant to be evolving documents. When</div><div>// you initially draft a JEP you don't need to fill out every section of</div><div>// the template, and in fact at that point you probably won't be able to</div><div>// do so. As you get feedback and build consensus around your proposal</div><div>// you'll revise the JEP accordingly. If your JEP is accepted and targeted</div><div>// then you'll continue to revise it as the work progresses so that, once</div><div>// it's complete, the JEP can serve as an authoritative record of what</div><div>// was actually done.</div><div>//</div><div>// The body of a JEP uses the Markdown markup language</div><div>// (<a href="http://daringfireball.net/projects/markdown/basics">http://daringfireball.net/projects/markdown/basics</a>).</div><div>//</div><div>// All sections are optional except those marked REQUIRED. Keep sections</div><div>// in the order shown below. If an optional section is not needed them</div><div>// simply omit it rather than write something like "None". Do not add</div><div><br></div><div>(I violated this, but since this text not final anyway it does not matter)</div><div><br></div><div>// sections beyond those defined in the template.</div><div>//</div><div>// Use lines of dashes ("----") under section titles, not equals signs</div><div>// ("===="). If you need subsections then use the "###" prefix before</div><div>// subsection headings and "####" before sub-subsection headings. Do not</div><div>// use HTML markup (<h2>, etc.) for section headings. In general, avoid</div><div>// HTML markup unless it's absolutely necessary.</div><div><br></div><div>Summary</div><div>-------</div><div><br></div><div>// REQUIRED -- Provide a short summary of the proposal, at most one or two</div><div>// sentences. This summary will be rolled up into feature lists, JSRs, and</div><div>// other documents, so please take the time to make it short and sweet.</div><div><br></div><div>Make the G1 garbage collector automatically release unused memory when idle.</div><div><br></div><div>Goals</div><div>-----</div><div><br></div><div>// What are the goals of this proposal? Omit this section if you have</div><div>// nothing to say beyond what's already in the summary.</div><div><br></div><div><br></div><div>Non-Goals</div><div>---------</div><div><br></div><div>// Describe any goals you wish to identify specifically as being out of</div><div>// scope for this proposal.</div><div><br></div><div><br></div><div><br></div><div>Success Metrics</div><div>---------------</div><div><br></div><div>// If the success of this work can be gauged by specific numerical</div><div>// metrics and associated goals then describe them here.</div><div><br></div><div>From paper?</div><div><br></div><div>Motivation</div><div>----------</div><div><br></div><div>// Why should this work be done? What are its benefits? Who's asking</div><div>// for it? How does it compare to the competition, if any?</div><div><br></div><div>Currently the JVM garbage collectors may not give back committed Java heap memory to the operating system in a timely manner. Its garbage collectors only shrink the Java heap at the end of a full collection. G1 in particular tries to completely avoid them, which means that it may never return Java heap memory unless forced externally.</div><div><br></div><div>This is particularly disadvantageous in a container environment where resources are paid by use. Even during phases where the VM only uses a fraction of its assigned memory resources, customers pay for all resources all the time, and cloud providers can not fully utilize their hardware.</div><div><br></div><div>If the VM were able to detect phases of heap underutilization ("idle" phases), and in turn automatically reduce its heap usage, both would benefit.</div><div><br></div><div>Shenandoah and OpenJ9's GenCon collector already provide similar functionality.</div><div><br></div><div>Description</div><div>-----------</div><div><br></div><div>// REQUIRED -- Describe the enhancement in detail: Both what it is and,</div><div>// to the extent understood, how you intend to implement it. Summarize,</div><div>// at a high level, all of the interfaces you expect to modify or extend,</div><div>// including Java APIs, command-line switches, library/JVM interfaces,</div><div>// and file formats. Explain how failures in applications using this</div><div>// enhancement will be diagnosed, both during development and in</div><div>// production. Describe any open design issues.</div><div>//</div><div>// This section will evolve over time as the work progresses, ultimately</div><div>// becoming the authoritative high-level description of the end result.</div><div>// Include hyperlinks to additional documents as required.</div><div><br></div><div>To accomplish this goal, the HotSpot JVM periodically triggers a full collection to maximally compact the Java heap and uncommit unused memory if below conditions are met.</div><div><br></div><div>Two full collections should not be separated by more than GCFrequency seconds. The GCFrequency value is ignored and therefore, i.e., no full collection is triggered, if:</div><div><br></div><div> - GCFrequency is zero;</div><div> - the average load on the host system is above MaxLoadGC. The average load is defined as per the os::load_avg() call. This check is ignored if MaxLoadGC is zero;</div><div> - the committed memory is above MinCommitted bytes. This check is ignored if MinCommitted is zero;</div><div> - the difference between the current heap capacity and the current heap usage is below MaxOverCommitted bytes. This check is ignored if MaxOverCommitted is zero;</div><div><br></div><div>All these command line options are dynamically user-defined variables. They can be modified at runtime.</div><div><br></div><div>Alternatives</div><div>------------</div><div><br></div><div>// Did you consider any alternative approaches or technologies? If so</div><div>// then please describe them here and explain why they were not chosen.</div><div><br></div><div>Similar functionality could be achieved via tools like jcmd or MBean, but has hidden costs: assuming that the check is performed using a cron-based task, in case of hundreds or thousands of containers on a node this may mean that the heap compaction action is performed at the same time by many of these containers, which gives very large CPU spikes on the host.</div><div><br></div><div>Another alternative option could be a Java agent which is automatically attached to each java process. Then the check time is distributed naturally as containers start at different time, plus it's less expensive on CPU because you do not launch any new process. However this method adds complexity to users outside of cloud hosting companies, which may prevent adoption.</div><div><br></div><div>Testing</div><div>-------</div><div><br></div><div>// What kinds of test development and execution will be required in order</div><div>// to validate this enhancement, beyond the usual mandatory unit tests?</div><div>// Be sure to list any special platform or hardware requirements.</div><div><br></div><div>No special testing environment needed.</div><div><br></div><div>Risks and Assumptions</div><div>---------------------</div><div><br></div><div>// Describe any risks or assumptions that must be considered along with</div><div>// this proposal. Could any plausible events derail this work, or even</div><div>// render it unnecessary? If you have mitigation plans for the known</div><div>// risks then please describe them.</div><div><br></div><div><br></div><div><br></div><div>Dependencies</div><div>-----------</div><div><br></div><div>// Describe all dependencies that this JEP has on other JEPs, JBS issues,</div><div>// components, products, or anything else. Dependencies upon JEPs or JBS</div><div>// issues should also be recorded as links in the JEP issue itself.</div><div>//</div><div>// Describe any JEPs that depend upon this JEP, and likewise make sure</div><div>// they are linked to this issue in JBS.</div><div><br></div><div>None.</div><div><br></div><div>(We can stuff references like the below in the comments section of the JEP I guess)</div><div><br></div><div><a href="https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/xxidletuningcompactonidle.html">https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/xxidletuningcompactonidle.html</a></div><div><br></div><div>Thanks,</div><div> Thomas</div><div></div><div></div><div></div></div></body></html>