{"id":617,"date":"2012-02-17T17:26:58","date_gmt":"2012-02-17T16:26:58","guid":{"rendered":"http:\/\/iamwcew.fr.oracle.com\/blog\/?p=617"},"modified":"2012-02-17T17:26:58","modified_gmt":"2012-02-17T16:26:58","slug":"tuner-au-mieux-une-jvm-hot-spot","status":"publish","type":"post","link":"https:\/\/gpmfactory.com\/index.php\/2012\/02\/17\/tuner-au-mieux-une-jvm-hot-spot\/","title":{"rendered":"Tuner au mieux une jvm hot spot"},"content":{"rendered":"<p><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\">De: Andreas Loew<br \/>\n<\/span><\/p>\n<p><span style=\"font-family: 'Times New Roman', serif; font-size: 12pt;\">from my point of view (10 years of experience with tuning Hotspot JVM in Sun PS) the CMS algorithm definitely is recommended.<br \/>\n<\/span><span style=\"font-family: 'Times New Roman', serif; font-size: 12pt;\">Regarding OutOfMemoryError, you must not see this error with any GC algorithm, but an OOM as such does not mean you that have to change the GC algorithm, but rather that you either have a memory leak or are trying to store too much data into the JVM which exceeds the configured heap size (-Xmx).<\/span><\/p>\n<p>I strongly recommend Charlie Hunt&rsquo;s new book for Hotspot GC tuning<br \/>\n<a href=\"http:\/\/www.amazon.com\/Java-Performance-Addison-Wesley-Charlie-Hunt\/dp\/0137142528\">http:\/\/www.amazon.com\/Java-Performance-Addison-Wesley-Charlie-Hunt\/dp\/0137142528<\/a><\/p>\n<p><!--more-->as well as my \u00ab\u00a0educated best guess\u00a0\u00bb sample JVM settings for a Coherence cache node as a starting point:<\/p>\n<p><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-server <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-d64<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (only for a 64-bit JVM with a max heap size of 32 GB) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-verbose:gc<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (and optionally <\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">-Xloggc:<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;your GC log target file&gt;) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-Xms<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;heapsize&gt;<\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">m<\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-Xmx<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;heapsize&gt;<\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">m <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:PermSize=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;permsize&gt;<\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">m<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (optimally determine the Perm Gen size really needed by looking at jvisualvm with VisualGC plugin when all classes have been loaded) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:MaxPermSize=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;permsize&gt;<\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">m<\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:NewSize=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;between heapsize\/4 and heapsize\/2&gt;<\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">m<\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:MaxNewSize=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;between heapsize\/4 and heapsize\/2&gt;<\/span><span style=\"font-size: 10pt; font-family: 'Courier New';\">m <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:SurvivorRatio=2<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (increase in even numbers up to 8 in case you note from looking at jvisualvm with VisualGC plugin that Survivor spaces are never filled up more than 60%)<\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+HandlePromotionFailure <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:TargetSurvivorRatio=80<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (somewhere between 60 to 80, decrease if you note direct Survivor space overflow) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:MaxTenuringThreshold=8 <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:SoftRefLRUPolicyMSPerMB=5000<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (\u00ab\u00a0a soft reference will survive (after the last strong reference to the object has been collected) for 5000ms times the number of megabytes of free space in the heap\u00a0\u00bb) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+AggressiveOpts <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+DoEscapeAnalysis <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+UseCompressedOops<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (only for a 64-bit JVM) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+DisableExplicitGC <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+UseParNewGC <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:ParallelGCThreads=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;n &#8211; number of cores you want to assign on average to this JVM on this machine&gt; (default value: (ncores &lt;= 8) ? ncores : 3 + ((ncores * 5) \/ 8)) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:ParallelCMSThreads=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;m &#8211; number of cores you want to use for concurrent GC while the app continues to run &#8211; typically choose m between n\/4 and n\/3&gt; (default value: (ParallelGCThreads + 3) \/ 4) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+UseConcMarkSweepGC <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:CMSWaitDuration=<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\">&lt;d &#8211; where d needs to be larger than the maximum time between two minor Young Gen collection cycles&gt; (from 6u27 onwards and in JDK7, you can set d = 0 instead to mean the same <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+CMSScavengeBeforeRemark <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+CMSClassUnloadingEnabled <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+ParallelRefProcEnabled <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+CMSParallelRemarkEnabled <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:CMSInitiatingOccupancyFraction=75<\/span><span style=\"font-size: 10pt; font-family: 'Times New Roman', serif;\"> (somewhere between 55 and 75, start with 75 and decrease in case CMS cannot keep up with the app) <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+UseCMSInitiatingOccupancyOnly <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:-TraceClassUnloading <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+PrintTenuringDistribution <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+PrintGCDateStamps <\/span><\/span><span style=\"font-size: 12pt; font-family: 'Times New Roman', serif;\"><br \/>\n<\/span><span class=\"bki-span\"><span style=\"font-size: 10pt; font-family: 'Courier New';\">-XX:+HeapDumpOnOutOfMemoryError <\/span><\/span><\/p>\n<p>And be sure to use the most recent HP JDK 6.0.13 \u00ab\u00a0(includes Oracle update 6u29)\u00a0\u00bb which is available to be able to make use of all the new features (CompressedOops, EscapeAnalysis)&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>De: Andreas Loew from my point of view (10 years of experience with tuning Hotspot JVM in Sun PS) the CMS algorithm definitely is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"ppma_author":[150],"class_list":["post-617","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"authors":[{"term_id":150,"user_id":1,"is_guest":0,"slug":"admin8700","display_name":"Patrick","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/209d5ed69b74d288390621ab4c1d3773?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/comments?post=617"}],"version-history":[{"count":0,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/617\/revisions"}],"wp:attachment":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/media?parent=617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/categories?post=617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/tags?post=617"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/ppma_author?post=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}