Tag cloud

JBoss (16) Fedora (5) Linux (4) Red Hat (4) JON (3) command line (3) 4.3 (2) JEE (2) JVM (2) Java (2) KVM (2) Oracle (2) Portal (2) Weblogic (2) installation (2) vs (2) /boot partition (1) Add-ons (1) Apache (1) Bundles (1) Business model (1) Byteman (1) CLASSPATH (1) EAP (1) EPP (1) Eclipse (1) Failover (1) Gnome (1) JAVA_OPTS (1) JBDS (1) JBoss Tools (1) JBossON (1) JConsole (1) JDK (1) JMS (1) JVM options (1) KDE (1) MBean (1) Network (1) Open Source (1) RHQ (1) Red Hat subscription (1) Thunderbird (1) Troubleshooting (1) Virtulization (1) WS (1) Webservices (1) Wireshark (1) classloading (1) clustering (1) comparison (1) debug (1) deployment (1) disable SELinux (1) disksize (1) error (1) fun (1) jboss.org (1) log (1) log4j (1) lvm (1) messaging (1) multiple WARs (1) patent FOSS (1) performance tuning (1) provisionning (1) scripting (1) services (1) switch (1) troll (1) upgrade (1) video (1) war (1) webapp (1) yum (1)

28 February 2011

JVM Performance tuning

To understand that tuning your Java Virtual Machine should not be underestimated, take a look at the various parameter that can be set starting your Java program (dates 28 Aug 2007):
http://blogs.sun.com/watt/resource/jvm-options-list.html
or the official Oracle list:
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
and the Tagtraum list:
http://www.tagtraum.com/gcviewer-vmflags.html

Also check out the article "Java Performance Tuning, Profiling, and Memory Management" on Dzone by :
http://java.dzone.com/articles/java-performance-tuning

And the last good pointer is the article of Pete Freitag:
http://www.petefreitag.com/articles/gctuning/

I also really liked this JVM deck of Simon Ritter :
http://www.javapassion.com/javase/GC_Performance.pdf

Ritter points out that:
--> Most new objects will die young
--> Concentrate effort on young generation (Eden)
--> Use the right tool for the job (Different GC algorithms for each generation)


Howto read gc.log
After adding the following JVM options:
-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/tmp/gc.log
You will find in the generated /tmp/gc.log something like:
[GC 34000 kb -> 21000 kb (0.018 sec] (The GC collects the young generation)
[Full GC 60000 kb -> 12000 kb (0.430 sec] (The Full GC collects the old generation, costs more CPU)


To analyse the /tmp/gc.log open it with the tool GCViewer.

Choose the Just-In-Time compiler
-classic (no JIT)
-client  (a lot of JIT compiling)
-server (optimized JIT compiling, for production environment)
this JVM option needs to be the first one in the list

JVM options to consider

For JVM performance tuning you will have to choose the
- Young generation option
- Old generation option

Generation
Collector
JVM options
Description
Young
Serial New
-XX:+UseSerialGC
(default until J2EE 1.4)
Single-threaded, stop-the-world, copying collector
Young
Parallel Scavenge /
Throughput
-XX:+UseParallelGC
(default JEE 5+)
Multi-threaded, stop-the-world, copying collector (CAN NOT to be used with CMS). Automatically used when -XX:+AggressiveHeap was specified.
Young
Parallel New
-XX:+UseParNewGC
Multi-threaded, stop-the-world, copying collector CAN be used along with CMS. Automatically used when CMS was specified for Old Gen.
Old
Serial Old /
Mark Sweep
Compact
-XX:+UseSerialGC




Single-threaded, stop-the-world, mark-sweep-compact (MSC) collector
Old
Parallel Old
-XX:+UseParallelOldGC
(JEE 6+)
Multi-threaded, stop-the-world, copying collector
Old
Concurrent Mark-Sweep / Concurrent Low Pause
-XX:+UseConcMarkSweepGC
Concurrent low pause collector that works sharing the application threads.
For example :
-server -Xms2000m -Xmx2000m -Xss512k -XX:+AggressiveHeap -XX:+UseParallelGC -verbose:gc -XX:+PrintGCTimeStamps -XX:+DisableExplicitGC -Xloggc:/tmp/jboss_GC.log

Sets the ratio between young and old generation.
-XX:NewRatio=3 means that the ratio between the young and old generation is 1:3; in other words, the combined size of eden and the survivor spaces will be one fourth of the heap.

Use cases
Q: Which GC to use when I have applications with a very large young generation heaps ?
A: -XX:+UseParallelGC


Monitor your JVM
JConsole
VisualVM
JRockit
JMAP

As you probably still have questions, refer to:

http://www.oracle.com/technetwork/java/hotspotfaq-138619.html

No comments:

Post a Comment