Hi all, I wanted to share a JVM setting that is improving clojure performance (for me) in long running processes: MaxPermSize and PermSize, which define the size of the permanent generation in the garbage collector.
I am doing heavy image processing, with many long-lived objects. Performance is great until, after 10 minutes or so from launching the JVM, the garbage collector seems to be running almost all the time. A look at the heap with "Control+\" on the terminal that runs java shows that the permanent generation is at 99% capacity, and the "eden", "from" and "to" spaces are at 0% ! The default permanent size is apparently 32 megabytes in jdk1.6.0_17 in an 8-core intel 64-bit machine with 16 Gb of RAM. The permanent size, according to JVM docs, stores objects that are seldom or never in need of being collected, like literal String instances and Class instances. So this is how I run the JVM in a 64-bit machine with 8 cores and 16 Gb of RAM, for image processing: java -Xms6g -Xmx6g --Xingc -XX:PermSize=512m -XX:MaxPermSize=512m -XX:CMSTriggerRatio=50 -XX:ParallelGCThreads=3 -XX:NewRatio=5 The fixed heap size helps. The incremental garbage collector also helps a lot--very few or no pauses. I reduced the number of parallel GC threads to 3 (defaults to as many as cores, if I recall correctly). And the NewRatio, which is the proportion of "eden" versus old or cms-generation, is 1:8 by default--so I made eden a bit bigger to prevent the GC from running too often. Finally, the lower CMSTriggerRatio (default is I think 80%) helps in triggering concurrent garbage collector before little heap remains free (which, when dealing with large images, may result in long pauses if its triggered too late). Performance does not degrade anymore. (Of course, YMMV.) [I have found by the way a list of nearly all JVM flags for 1.6.0 with minimal explanations here: http://www.md.pp.ru/~eu/jdk6options.html ] Hope that helps somebody. Albert -- Albert Cardona http://albert.rierol.net -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en