Wednesday, December 18, 2013

Should I be Tuning GC?

Java VM now do a pretty good job picking a GC algorithm. Often any tuning we do make things worse. I have seen several times that all you have to do to fix a issue is take take away GC tuning parameters that are there. (Unfortunately often after weeks of debugging)

How do you decide to GC or not to GC?

To measure GC, we use a measure called JVM throughput. JVM throughput measures the percentage of time it did not spent on GC (in other words, time it spending doing useful work). If JVM throughput is greater than 90%, you should NOT be tuning GC. If it is less, then may be you should.

OK, then how do you measure JVM throughput?
  1. Run you program with following GC parameters.This will write the GC logs to gc.log file of the home directory
  2. -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
    
  3. To analyse, download and unzip GC Viewer from https://github.com/chewiebug/GCViewer/releases
    Start the GC viewer by running following command from the unzipped directory.
    $java -jar gcviewer-1.32.jar
    
  4. Then open the gc.log file and it shows the throughput.


Also you can use IBM pattern modelling tool from alpha works.

No comments: