Java Performance Series – 2

7 Apr

Coming back to Java performance series, let me write something about various x/xx (thank god they didn’t come up with xxx stuff) options that comes bundled with java virtual machine. To begin with some valuable information copy pasted from oracle site,

Below is the some key things which we need to keep in mind always as we move forward with JDK,

  • Options that begin with -X are non-standard (not guaranteed to be supported on all VM implementations), and are subject to change without notice in subsequent releases of the JDK.
  • Options that are specified with -XX are not stable and are not recommended for casual use. These options are subject to change without notice.

Oracle classifies various VM options into below 3 categories,

  • Behavioral options change the basic behavior of the VM.
  • Performance tuning options are knobs which can be used to tune VM performance.
  • Debugging options generally enable tracing, printing, or output of VM information.

There is whole lot of information that can be pulled out of virtual machine which we can use to either identify/diagnose or get information from VM and analyze as how performance of the VM looks like. Some of the options needs to be set via server xml files and some can be pulled out via JMX. Most of the monitoring tools that are in market today uses JMX to pull the information from the JVM.

So let’s understand some of the various key gc debugging options flags that can used to pull Garbage collection stats from the java virtual machine. Please note that usage and command line differs across the oracle jdk /IBM jdk that is one option flag working perfectly in oracle JDK might not work or exist in IBM JDK. (Thank God BEA was taken over by Oracle, else we might have BEA JROCKKIT JVM as well to know and understand).

Below are the Oracle JDK Flags that are used to print the GC Information

-XX:+PrintGCTimeStamps prints a time stamp representing the number of seconds since the HotSpot VM was launched until the garbage collection occurred.

-XX:+PrintGCDetails provides garbage collector-specific statistics and thus varies depending on the garbage collector in use.

-Xloggc :< filename> directs the garbage collection information to the file named <filename>.

-XX:+PrintGCDateStamps Prints the garbage collection information with current date and timestamps. Information with this flag looks like below,

2012-04-08T02:57:10.213-0200: [GC [PSYoungGen: 623648K->323422K (300226K)]

192109K->123528K (13136848K), 0.534183 secs]

[Times: user=3.23 sys=0.09, real=0.32 secs]

The date stamp field, 2012-04-08T02:57:10.213-0200, uses the ISO 8601 date and time stamp. The output has the following form: YYYY-MM-DDTHH-MM-SS.

mmm-TZ where:

YYYY is the four-digit year.

MM is the two-digit month; single-digit months are prefixed with 0.

DD is the two-digit day of the month; single-digit days are prefixed with 0.

T is a literal that denotes a date to the left of the literal and a time of day to the right.

HH is the two-digit hour; single-digit hours are prefixed with 0.

MM is the two-digit minute; single-digit minutes are prefixed with 0.

SS is the two-digit second; single-digit seconds are prefixed with 0.

SS is the two-digit second; single-digit seconds are prefixed with 0.

mmm is the three-digit milliseconds; single- and two-digit milliseconds are prefixed with 00 and 0, respectively.

TZ is the time zone offset from GMT.

IBM JDK uses the below flags for getting information about garbage collection stats

-verbose: gc

Prints out information about garbage collections to standard out.

-Xverbosegclog :< path to file><filename [, X, Y]>

Prints out information about garbage collections to a file. If the integers X and Y are specified, the output is redirected to X files each containing output from Y GC cycles.

Having all these kinds of information gives us a proper understanding as how people often collect and troubleshoot garbage collection issues.

In the next post, I will try to explain some more key options that we need to know about java performance tuning. I will try to see if I can explain as how we can also use those command lines in real time with some example. (I thought of pulling out some GC numbers from my laptop, but there exists a risk that I might corrupt my project files , I am not yet full time developer J ,need to take copy/backup of my current application).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: