<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 5 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=DE link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Dont worry about the sweep, G1 is like CMS mostly concurrent.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I would suggest to test it with GC log enabled and then you can worry. Most likely you want to allow it to kick of GC later so you can save some concurrent CPU. You also need to fear the FullGC when your regions become to fragmented (this hopefully does not happen if the LRU frees lots of object allocated at the same time in the same Region, but you never know. You might unfortunatelly Need to have 30% or more unused heap to defend against that.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>There is BTW a Mailing list for GC Usage as opposed to development.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Gruss</p><p class=MsoNormal>Bernd</p><p class=MsoNormal>-- <br>http://bernd.eckenfels.net</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>Von: </b><a href="mailto:andrew_nuss@yahoo.com">Andy Nuss</a><br><b>Gesendet: </b>Mittwoch, 13. Dezember 2017 22:56<br><b>An: </b><a href="mailto:kirk@kodewerk.com">Kirk Pepperdine</a>; <a href="mailto:hotspot-gc-dev@openjdk.java.net">hotspot-gc-dev@openjdk.java.net</a><br><b>Betreff: </b>Re: how to tune gc for tomcat server on large machine that usesalmost all old generation smallish objects</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'>Let me try to explain.  On a 16 gig heap, I anticipate almost 97% of the heap in use at any given moment is ~30 and ~100 char strings.  The rest is small pointer objects in the ConcurrentHashMap, also longly held, and tomcat's nio stuff.  So at any moment in time, most of the in-use heap (and I will keep about 20% unused to aid gc), is a huge number of longly held strings.  Over time, as the single servlet receives requests to cache newly accessed key/val pairs, the number of strings grows to its maximum I allow.  At that point, a background thread sweeps away half of the LRU key/value pairs (30,100 char strings).  Now they are unreferenced and sweepable.  That's all I do.  Then the servlet keeps receiving requests to put more key/val pairs.  As well as handle get requests.  At the point in time where I clear all the LRU pairs, which might take minutes to iterate, G1 can start doing its thing, not that it will know to do so immediately.  I'm worried that whenever G1 does its thing, because the sweepable stuff is 100% small oldgen objects, servlet threads will timeout on the client side.  Not that this happens several times a day, but if G1 does take a long time to sweep a massive heap with all oldgen objects that are small, the *only* concern is that servlet requests will time out during this period.<o:p></o:p></span></p><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'>Realize I know nothing about GC, except that periodically, eclipse hangs due to gc and then crashes on me.  I.e. after 4 hours of editing.  And that all the blogs I found talked about newgen and TLAB and other things assuming typical ephemeral usage going on which is not at all the case on this particular machine instance.  Again, all longly held small strings, growing and growing over time steadily, suddenly half are freed reference wise by me.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'>If there are no GC settings that make that sweepable stuff happen in a non-blocking thread, and tomcat's servlets could all hang once every other day for many many seconds on this 16 gig machine (the so-called long gc-pause that people blog about), that might motivate me to abandon this and use the memcached product.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif'><o:p> </o:p></span></p></div><div id="yahoo_quoted_3833318302"><div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>On Wednesday, December 13, 2017, 12:15:38 PM PST, Kirk Pepperdine <kirk@kodewerk.com> wrote: <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><div id=yiv5340352325><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>Hi Andy,<o:p></o:p></span></p><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>On Dec 13, 2017, at 8:34 PM, Andy Nuss <<a href="mailto:andrew_nuss@yahoo.com" target="_blank">andrew_nuss@yahoo.com</a>> wrote:<o:p></o:p></span></p></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p><div><div><div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>Thanks Kirk,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>The array is just a temporary buffer held onto that has its entries cleared to null after my LRU sweep.  The references that are freed to GC are in the ConcurrentHashMaps, and are all 30 char and 100 char strings, key/vals, but not precisely, so I assume that when I do my LRU sweep when needed, its freeing a ton of small strings, <o:p></o:p></span></p></div></div></div></div></blockquote><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><br><br><o:p></o:p></span></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>which G1 has to reallocate into bigger chunks, and mark freed, and so,<o:p></o:p></span></p></div></div></div></div></blockquote><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>Not sure I understand this bit. Can you explain what you mean by this?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><br><br><o:p></o:p></span></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>so that I can in the future add new such strings to the LRU cache.  The concern was whether this sweep of old gen strings scattered all over the huge heap would cause tomcat nio-based threads to "hang", not respond quickly, or would G1 do things less pre-emptively.  Are you basically saying that, "no tomcat servlet response time won't be significantly affected by G1 sweep”?<o:p></o:p></span></p></div></div></div></div></blockquote><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>I’m not sure what you’re goal is here. I would say, design as needed and let the collector do it’s thing. That said, temporary humongous allocations are not well managed by the G1. Better to create up front and cache it for future downstream use.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>As for a sweep… what I think you’re asking about is object copy costs. These costs should and typically do dominate pause time. Object copy cost is proportional to the number of live objects in the collection set (CSet). Strings are dedup’ed after age 5 so with most heap configurations, duplicate Strings will be dedup’ed before they hit tenured.<br><br><o:p></o:p></span></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>Also, I was wondering does anyone know how memcached works, and why it is used in preference to a custom design such as mine which seems a lot simpler.  I.e. it seems that with "memcached", you have to worry about "slabs" and memcached's own heap management, and waste a lot of memory.<o:p></o:p></span></p></div></div></div></div></blockquote><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>I’m the wrong person to defend the use of memcached. It certainly does serve a purpose.. that said, to use it to offload temp object means you end up creating your own garbage collector… and as you can see by the efforts GC engineers put into each implementation, it’s a non-trivial under-taking.<o:p></o:p></span></p></div><div id=yiv5340352325yqtfd65405><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>Kind regards,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'>Kirk<o:p></o:p></span></p></div></div></div></div></div></div></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A'><o:p> </o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>