tag:blogger.com,1999:blog-5560209661389175529.post2236087059768112091..comments2021-11-26T19:34:10.855+00:00Comments on Mechanical Sympathy: Java Garbage Collection DistilledMartin Thompsonhttp://www.blogger.com/profile/15893849163924476586noreply@blogger.comBlogger22125tag:blogger.com,1999:blog-5560209661389175529.post-40015835848198238172020-09-21T11:27:44.582+01:002020-09-21T11:27:44.582+01:00nice blognice blogNorman Jadehttps://www.blogger.com/profile/13322594734453799109noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-74405409779089738232017-09-01T09:15:42.560+01:002017-09-01T09:15:42.560+01:00The default is now parallel collection of the old ...The default is now parallel collection of the old and young generation if the hardware supports it.Martin Thompsonhttps://www.blogger.com/profile/15893849163924476586noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-5308874298890366792017-09-01T09:03:29.398+01:002017-09-01T09:03:29.398+01:00Thanks so much to share! This is the most comprehe...Thanks so much to share! This is the most comprehensive and well documented article about Java GC have ever seen. There is one bullet point I do not follow is that two form of parallel collectors explanation above. Based on Java 8 doc(https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html and http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html), both minor and major collections are executed in parallel with -XX:+UseParallelGC, enabling -XX:+UseParallelGC would automatically enable -XX:+UseParallelOldGC. How should we understand this, the default option for major collections of -XX:+UseParallelGC is single-thread? <br /><br />Thanks, <br />Ding Anonymoushttps://www.blogger.com/profile/04416698056697949003noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-36680431138637168912017-07-08T19:27:13.759+01:002017-07-08T19:27:13.759+01:00Very nice and informative post!
Thanks!Very nice and informative post!<br /><br />Thanks!Jim Roskindhttps://www.blogger.com/profile/16478340310258573145noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-82390603693301630472016-04-03T18:32:44.750+01:002016-04-03T18:32:44.750+01:00Garbage collection is a bad design decision that h...Garbage collection is a bad design decision that has haunted java throughout its lifetime, The guys at apple figured this out early and quickly replaced garbage collection with Automatic reference countingAnonymoushttps://www.blogger.com/profile/16447005515590351739noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-49464156312274736242016-04-01T05:43:11.401+01:002016-04-01T05:43:11.401+01:00I have come across a GCeasy tool http://gceasy.io ...I have come across a GCeasy tool http://gceasy.io for GC log analysis. It is pretty good with insights and graphs.<br />stephenhttps://www.blogger.com/profile/09535521389420801871noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-12147242171066970572015-12-29T14:27:19.319+00:002015-12-29T14:27:19.319+00:00I see that post is very informative, thanks for sh...I see that post is very informative, thanks for sharing thoughts.Nickole Dinardohttps://www.blogger.com/profile/05435675622017105709noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-88166918075046874252014-04-05T05:37:26.129+01:002014-04-05T05:37:26.129+01:00So, on the topic of CMS, wanted to mention a patte...So, on the topic of CMS, wanted to mention a pattern we found helpful on a past application. For this application, long pause times were not acceptable. However, a complicating factor is that objects needed to be kept in memory for an indeterminate amount of time until the object was done being used. At that point, it could be dereferenced and the memory reclaimed. What we found helpful in this case was, trading even more throughput for latency, to enable ExplicitGcInvokesConcurrent and to do explicit System.gc() on a regular basis, triggered either by a pre-set # of evictions, or (just to cover our bases) by a time interval without any other explicit GC. For this application, the objects being allocated were generally fairly uniform in size, so although we were certainly fragmenting the tenured generation, the evictions would hopefully help leave large enough free blocks to enable promotions to continue unhindered. We found the strategy fairly effective at keeping max-pause in the 10s of ms (though general case was 1-5ms), and we never saw any full GC due to concurrent mode failure or fragmentation. As it so happens, that was still not consistent enough, so other solutions were pursued. But it is a pattern which could be of use (and be improved upon?) for situations where it's difficult to define the heap needs of the system in strictly generational terms, assuming you can put up with the reduction in throughput. At any rate, I think ExplicitGcInvokesConcurrent is a sorely neglected flag...if you use it nowhere else, it's a godsend for an IDE (as is using CMS).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-91166470029645396482014-03-10T17:24:37.149+00:002014-03-10T17:24:37.149+00:00To clarify what I mean by allocation rate, I mean ...To clarify what I mean by allocation rate, I mean rate in bytes allocated. The faster this rate the more frequent the young generation collections. Hope that is clear?Martin Thompsonhttps://www.blogger.com/profile/15893849163924476586noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-69637690783996954982014-03-09T18:08:36.400+00:002014-03-09T18:08:36.400+00:00Thanks for the tutorial, martin.
You mentioned fre...Thanks for the tutorial, martin.<br />You mentioned frequency of minor gc is proportional to the rate object is allocated, not the amount of total memory newly allocated objects adds up to, as long as young gen's threshold is not reached yet. is my understanding correct?Anonymoushttps://www.blogger.com/profile/13671559019933847099noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-20699161901303298612014-01-29T23:05:04.787+00:002014-01-29T23:05:04.787+00:00Hi Martin,
Are there any phases/steps in G1 GC th...Hi Martin,<br /><br />Are there any phases/steps in G1 GC that are not captured with -XX:+PrintGCDetails. The times captured in parallel phase, sequential phases [Code Root Fixup, Clear CT, Other] often do not add to the pause time induced by GC (differ by 9-10 ms always). Sometimes the discrepancy is as high as .5 seconds. From the worker end times, this time is spent after the parallel phase. Is this the initial mark phase piggy backed on to young collection? How do i trace the source of these delays?Are there any other flags that i am overlooking to enable more finer logging?<br /><br />I also posted a question on stackoverflow with the GC log and parameters<br /><br />http://stackoverflow.com/questions/21416774/g1-garbage-collector-tuning<br /><br />ThanksTejahttps://www.blogger.com/profile/05784379422866826606noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-2103955368113674972013-12-23T22:59:42.770+00:002013-12-23T22:59:42.770+00:00Yes, such load tests aka benchmarks are very usefu...Yes, such load tests aka benchmarks are very useful to investigate GC because they are easier to understand than a full application and cheaper to execute with potentially a large number of values for different JVM parameters. It is relatively easy to write meaningful micro benchmarks. Find samples, results and discussion here:<br />http://blog.mgm-tp.com/2013/12/benchmarking-g1-and-other-java-7-garbage-collectors/<br />Regards<br />AndreasAnonymoushttps://www.blogger.com/profile/08935432174451647516noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-81595482556201835122013-09-19T20:16:30.978+01:002013-09-19T20:16:30.978+01:00excellent info!
I do monitor the performance of ap...excellent info!<br />I do monitor the performance of app requests with spf4j (www.spf4j.org) and use distribution charts (similar to dtrace llquanitze http://dtrace.org/blogs/bmc/2011/02/08/llquantize/ + http://dtrace.org/blogs/brendan/2013/05/19/revealing-hidden-latency-patterns/) <br />GC is always clearly visible...<br /><br />Sometimes I wish Knuth never said "optimization is the root of all evil"... too many people just write a lot of turd and quote knuth as a excuse....<br /><br />I say:<br /><br />writing rubbish code for no good reason is the root of all evil :-)<br /><br />cheers, keep up the good work!<br /><br />-- ZoltanZoltan Farkashttps://www.blogger.com/profile/13403082247059421847noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-58710990659616452962013-09-04T11:18:42.383+01:002013-09-04T11:18:42.383+01:00Two very good questions and difficult to answer in...Two very good questions and difficult to answer in a blog comment.<br /><br />GC Roots are easy to find things like references from the stack or static references in a class.<br /><br />The 2 survivor regions allow you to keep data contiguous in memory for fast relocation and scanning. On each minor collection, the collector only copies what is still reachable thus efficiently allowing objects to die under the weak generational hypothesis.<br /><br />To learn more I'd recommend reading the following book on GC.<br /><br />"The Garbage Collection Handbook" - http://www.amazon.co.uk/The-Garbage-Collection-Handbook-Management/dp/1420082795/Martin Thompsonhttps://www.blogger.com/profile/15893849163924476586noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-78063759644972830022013-07-27T13:48:54.515+01:002013-07-27T13:48:54.515+01:00Are there specific load tests for investigating G1...Are there specific load tests for investigating G1 or other GC's that you aware of ? These could be tests that the GC teams use for testing but could be helpful to understand GC's without relying on an actual running system.<br /><br />Thanks.Mohan Radhakrishnanhttps://www.blogger.com/profile/08457140016320542845noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-63431241626838279082013-07-24T01:35:48.059+01:002013-07-24T01:35:48.059+01:00thanks for the article! good insights into the dif...thanks for the article! good insights into the different jvm options.Anonymoushttps://www.blogger.com/profile/07836092365022949600noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-72230644137029191922013-07-19T05:49:14.208+01:002013-07-19T05:49:14.208+01:00Thanks for another great, informative article.Thanks for another great, informative article.Ben Hutchisonhttps://www.blogger.com/profile/04698002385923057473noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-90151947240883494582013-07-18T14:38:36.457+01:002013-07-18T14:38:36.457+01:00Your example is pretty much the pathological case ...Your example is pretty much the pathological case for most garbage collectors. A much better solution to that problem is to use the Disruptor but I see from your question that you do not want an alternative design suggestion.<br /><br />If you provided a GC log there might be some CMS tuning options to make things a bit better but it is hard to tell without the logs. Are the pauses due to a FullGC or are they due to Remark phase for example? If a FullGC it might be that CMS is not starting early enough to keep up.<br /><br />What is the real problem you are addressing because the contrived one seems a bit crazy?<br /><br />If you want to have such a design pattern then the best JVM for you is Azul Zing.Martin Thompsonhttps://www.blogger.com/profile/15893849163924476586noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-64310085076021471962013-07-18T14:21:43.645+01:002013-07-18T14:21:43.645+01:00Hello Martin,
Thanks for great posts. I like your ...Hello Martin,<br />Thanks for great posts. I like your comprehensive style.<br />Maybe you also could participate in this discussion where I review a particular easily repeatable GC problem:<br />http://stackoverflow.com/questions/17654964/gc-pause-tuning-of-long-fifo-queue-application<br /><br />I tried to get some useful hints on GC tunning, however it seems nobody provided a good answer yet.Anonymoushttps://www.blogger.com/profile/03726715173274195118noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-6161410182763578752013-07-17T13:18:43.631+01:002013-07-17T13:18:43.631+01:00Thanks. I've added the links.Thanks. I've added the links.Martin Thompsonhttps://www.blogger.com/profile/15893849163924476586noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-80147839768809559882013-07-17T13:01:59.408+01:002013-07-17T13:01:59.408+01:00The sentence "This can be achieved by capturi...The sentence "This can be achieved by capturing the response time of every test request in a histogram, and you can read more about that here." Seems to be missing a link.Richhttps://www.blogger.com/profile/07756463745034517324noreply@blogger.comtag:blogger.com,1999:blog-5560209661389175529.post-69962770945484483422013-07-17T09:30:58.863+01:002013-07-17T09:30:58.863+01:00Indeed GC is one of the most underdocumented stuff...Indeed GC is one of the most underdocumented stuff (at least its kind of unorganized ..)<br />I have done some benchmarks and tests evaluating the effects of the different flags here:<br /><br />http://java-is-the-new-c.blogspot.com/Rüdiger Möllerhttps://www.blogger.com/profile/03711813786574992852noreply@blogger.com