lauantai 15. elokuuta 2009

VisualVM CPU profiling on 64-bit JVM in Linux, solution for JVM crashing problem

I've had problems profiling Java apps (including Grails/Groovy apps) on my development machine which is a Lenovo T500 laptop running Ubuntu Linux 9.04 64-bit.
After turning on CPU profiling for a Java process in VisualVM, the JVM would always crash.

#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f6479671aa3, pid=13370, tid=140068334713168
#
# JRE version: 6.0_14-b06
# Java VM: Java HotSpot(TM) 64-Bit Server VM (14.0-b15 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x6a7aa3]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#


I was able to get around the JVM crashing problem with these steps:

  1. Turn off CPU frequency scaling on all CPU cores (example for 2 cores):
    sudo cpufreq-selector -c 0 -g performance; sudo cpufreq-selector -c 1 -g performance

    You can also you Gnome's CPU Frequency scaling monitor to select "performance" profile for both cpus (remember to add applets for all cpu cores)

  2. Reset calibration data in VisualVM (Tools->options->reset calibration data) and restart VisualVM.

  3. Start the JVM you want to profile with -XX:+UseParallelGC -Xshare:off options (JVM bug workaround: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6862295).



I think that CPU frequency scaling makes the JVM crash on Linux 64 bit JVM (Ubuntu 9.04 + Sun JVM 1.6.0_14). Profiling won't give proper results with frequency scaling and that's also a good reason to turn it off while profiling.

Hope this tips helps anyone having problems profiling apps running in Sun 64 bit 1.6.0 JVM on Linux.

Ei kommentteja:

Lähetä kommentti