The Art of Java Application Performance Analysis and Tuning – Part 5

This is the fifth article in the series of articles exploring the tools and techniques for analyzing, monitoring, and improving the performance of Java applications.

The Art of Java Application Performance Analysis and Tuning-Part 1                                      The Art of Java Application Performance Analysis and Tuning-Part 2                                     The Art of Java Application  Performance Analysis and Tuning-Part 3                                       The Art of Java Application  Performance Analysis and Tuning-Part 4

The Art of Java Application  Performance Analysis and Tuning-Part 6                                     The Art of Java Application  Performance Analysis and Tuning-Part 7

In this blog we will continue to look at some of the useful tools for analyzing the Java application programs.

IBM Health Center

Some of the discussed tools (Jmap ) works for Oracle Hot Spot VM only.

The IBM Monitoring and Diagnostic Tools for Java – Health Center is a tool from IBM which enables you to assess the current  status of a running Java application on IBM Java VM. This is very good low-overhead diagnostic tool and API for monitoring an application running on an IBM Java Virtual Machine. This works very well even in high heap memory usage applications.

Using IBM Health Center we can

  1. Identify if native or heap memory is leaking
  2. Discover which methods are taking most time to run
  3. Visualize and tune garbage collection
  4. View any lock contentions
  5. Monitor your applications Thread activity
  6. Detect deadlock conditions in your application
  7. Gather class histogram data (Equivalent to jmap -histo:live)

The Health Center tool is provided in two parts:

The Health Center client: is a GUI-based diagnostics tool for monitoring the status of a running Java Virtual Machine (JVM), installed within the IBM Support Assistant (ISA) Workbench.

The Health Center agent: provides the mechanism by which the Health Center client obtains information about your Java application. The agent uses a small amount of processor time and memory and must be manually installed in an IBM JVM.

Fig G. shows an overview of where the Health Center client and agent are located, when installed in ISA and the JVM.

Fig G. Location of Health Center client and agent

Fig G. Location of Health Center client and agent

Steps to install/use Health Center:

  1. Step 1 – Install the Health Center client:
  2. Step 2 – Launch the Health Center client:
  3. Step 3- Enable your application for monitoring:
  4. Step 4 -Connect Health Center to the enabled Java application:

Above steps are explained in

https://www.ibm.com/developerworks/java/jdk/tools/healthcenter/getting_started.html

Configuring and Connecting Java Application

Installing the Health Center agent: Most of the IBM Java Runtime Environments (JREs) already have a Health Center agent installed.  If installed the “jre/lib” folder contains healthcenter.properties file.

If agent is not installed then install the agent by following instructions from below link.

http://publib.boulder.ibm.com/infocenter/hctool/v1r0/index.jsp?topic=%2Fcom.ibm.java.diagnostics.healthcenter.doc%2Ftopics%2Finstallingagent.html

Configure and start the Health Center agent: You can start the Java application with enabling health center agent by adding the -Xhealthcenter:port=1965,level=headless property to java command line.
More detailed options at:

http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/configuringagent.html

http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/enablingagent.html
Install the Health Center client: : Follow the below link to installation

https://www.ibm.com/developerworks/java/jdk/tools/healthcenter/getting_started.html
Launch Health Center Client:

  1. Start the ISA Workbench (From Windows Programs menu)
  2. From the Welcome page, click Analyze Problem.
  3. On the “Analyze Problem” tab, select Tools option
  4. You will be presented with a list of all the installed tools. Select “IBM Monitoring and Diagnostic Tools for Java – Health Center” and then click on Launch.(Fig H.).
  5. The Health Center application will now launch and the Health Center: Connection wizard will be displayed.

Important note: Your application must be enabled for monitoring before Health Center can be connected.

Fig H. ISA Main page

Fig H. ISA Main page

Connecting to a Java application using the Health Center client: Select New Connection from the File menu of an Health Center client.
A connection wizard is displayed (Fig I.). Ensure that you have enabled your application for monitoring then click Next.  Specify the host name and port number. The Health Center makes a connection using these details.

Fig I ISA Connect Page

Fig I. ISA Connect Page

More Details at:

http://publib.boulder.ibm.com/infocenter/hctool/v1r0/topic/com.ibm.java.diagnostics.healthcenter.doc/topics/connectingtoJVM.htm

ISM Health Center Options

Once you have connected Health Center to an application, Health Center Client is composed of following options (Fig. J)

  1. Classes: Displays information about classes loaded and class histogram.
  2. Garbage Collection:: Displays information about Garbage Collection and memory use.
  3. I/O: Displays information about application I/O Activity.
  4. Profiling:: Displays information about application method profiling.
  5. Threads: Displays information about the Java application threads
  6. Native Memory: Displays information about the Native Memory of Java application
  7. Others:There are other useful options like Locking , I/O, Environment etc..
Fig J. ISA Health Center Options Page

Fig J. ISA Health Center Options Page

Monitoring Method Profiling

Method profiling (Fig K.) can be used diagnose applications showing high CPU usage. It shows where the application is spending  its time, by giving full call stack information for all sampled methods.

By identifying the hot methods/mostly called methods, we can optimize the methods/application logic to improve the performance.

Fig K. Method Profiling

Fig K. Method Profiling

Monitoring Garbage Collection and Memory

The Memory tab (Fig L.) provides information about memory consumption and Garbage Collection.  This can be used to analyze OutOfMemory (or) max resource usage scenarios.

Fig L. Monitoring Garbage Collection

Fig L. Monitoring Garbage Collection

Monitoring Class Loading

The Classes tab (Fig. M) displays information about class loading. This gives the number of classes loaded in the system.

The “Class histogram data” button option is the simple way to get the live object instances in the heap memory.  This is equivalent to jmap -histo:live option.

This gives the histogram of class names with number of instances and no. of bytes. This will be useful in OutOfMemomy and  high memory usage situations. Using this histogram we can identify which class has more number of instances and size.

We can get this output at regular intervals and can analyze to identify objects which are growing.

Fig M. Monitoring Class Loading

Fig M. Monitoring Class Loading

Monitoring Thread Information

The Threads option (Fig N.) provides information about thread use. It gives the number of threads running in the application.  We can get the “stack trace” of a particular thread by clicking the thread name on left side panel.

If the number of threads increasing continuously then we can suspect the thread leak.

Fig N. Monitoring Threads

Fig N. Monitoring Threads

Monitoring Native Memory Usage

We can monitor the Native Memory by using “Native Memory” option [Fig O.] Native Memory is the memory used by the Java application other than heap memory. This memory contains the Thread Memory/Stack Size, Direct memory  allocations (-XX:MaxDirectMemorySize=1G ) etc.. This is useful for analyzing the thread leak and native memory leaks..

Fig O. Monitoring Native Memory

Fig O. Monitoring Native Memory

Monitoring Application I/O Activity

I/O Option [Fig. P] gives the I/O activity of the application.

Fig P. Monitoring I/O Activity

Fig P. Monitoring I/O Activity

More Details at:

https://www.ibm.com/developerworks/java/jdk/tools/healthcenter/

http://publib.boulder.ibm.com/infocenter/hctool/v1r0/index.jsp

http://publib.boulder.ibm.com/infocenter/hctool/v1r0/index.jsp?topic=%2Fcom.ibm.java.diagnostics.healthcenter.doc%2Fhomepage%2Fplugin-homepage-hc.html

Advertisements
This entry was posted in java and tagged , . Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s