Profiling J2SE 5.0 based applications using Eclipse TPTP v4.3

The following document explains how the features of JVM 5.0 can be leveraged in TPTP to profile J2SE applications. The new profiling feature
in TPTP uses JVMTI to collect and report statistics using the same look and feel as the current Java profiler based on the experimental JVMPI interface.


Contents

Introduction
    Installing the JVMTI Feature
        Pre-Requisites
    Eclipse Client
    New Java Profiler Runtime
    Configuring the Eclipse Client
Profiling an Application
    Profiling Options
        Other Execution Profile Views
        Managing Filters
    Execution Profile of an Eclipse Application
    Memory Profile of an Eclipse Application
    Thread Profile of an Eclipse Application
Command Line Profiling using the New Java Profiler
Limitations
Feedback   

Introduction

The Eclipse Test & Performance Tools Platform (TPTP) New Java Profiler can be used to profile Eclipse plug-ins, local Java applications or complex applications running on multiple hosts and different platforms. The New Java Profiler is designed to work with Java applications based on Java 2 Standard Edition 5.0 (Java 1.5) and beyond.

The New Java Profiler is based on the Java Virtual Machine Tool Interface (JVMTI) introduced in J2SE 5.0, which replaces the earlier experimental Java Virtual Machine Profiler Interface (JVMPI). The Profiler uses a substantially different philosophy from the current TPTP JVMPI-based Profiler. Instead of relying on VM-generated events for monitoring application behavior (such as method entry and exit events, object allocations and so on) it uses Byte Code Instrumentation (BCI) to inject small pieces of code which tracks the application execution. This technique allows for efficient monitoring of specific parts of the application, without imposing a noticeable overhead on other parts of the application that are not being monitored.

This technology preview release of the New Java Profiler includes an Execution Time Analysis (CPU Profiling), Memory (Heap) Profiling, and Thread Profiling.

Installing the JVMTI Feature

The JVMTI Java profiler features in TPTP is offered as a technology preview item. The following sections describe how the features can be downloaded and setup to successfully start a profiling session.

Pre-Requisites

Eclipse Client

Download the New Java Profiler client (JVMTI client) and extract the plugins to your directory. The JVMTI Client is available under the "New Java Profiler" section of the TPTP 4.3 Download page.

New Java Profiler Runtime

Download the New Java Profiler runtime and extract the files to the <New Technology Agent Controller install-home> directory. The runtime files are extracted to the plugins directory of the new technology Agent Controller. Make sure you download the runtime version that matches your target platform. The New Java Profiler is available under the "New Java Profiler" section of the TPTP 4.3 Download page.

Configuring the Eclipse Client

The New Java Profiler works with the New Technology Agent Controller. The client should be configured to connect to the new technology Agent Controller port. This is configured in the file serviceConfig.xml in the new technology Agent Controller <install-home>/config directory. The default client connection port number of the new technology Agent Controller is 10006 (see Figure 1).

Note 

Refer to the JVMTI Release Notes for any special requirements for the Intel 64 or IA-64 Linux platforms.



Figure 1 - Preference page

Profiling an Application

The JVMTI data collector is associated with all launch items that appear under the profile launch configuration. The sections below describe profiling the Eclipse workbench using the new Java profiler.  A number of different Java application types can also be profiled using the new Java profiler.

Profiling Options

Default filters and profiling options are provided in the profiler launch configuration. You can override the default options by clicking on the Edit options button.

This profiler is a Dynamic bytecode instrumentation based profiler.  The profiler lets you control precisely which parts of an application are profiled and only relevant information is reported. Only the instrumented parts of your application are profiled while the rest of your application runs at full speed.  This minimizes the impact on application performance. The default filter set in the profiler avoids instrumentation in core Java classes. Additionally, there is a smart filtering capability to not instrument "simple" methods (getters and setters).

Other Execution Profile Views

The Profiling and Logging perspective provides context specific views for analyzing your application. Right click the agent in the Profiling navigator that appears under the Profiling Monitor view to get a listing of the available views (see Figure 2).



Figure 2 - Available Execution Profile Views

Managing Filters

You can manage the amount and type of information that is collected using the Manage Filters option within the Memory Statistics window.  In addition to a number of typical range options, you can also select Manage Filters > Manage Filters to control the range and information type directly.  Figure 3 shows the Manage Filters menu.



Figure 3 - Manage Filters Menu

Execution Profile of an Eclipse Application

The JVMTI profiler can be used to profile any Eclipse Plugins, Eclipse RCP applications, JavaEE applications, and Java applications. This document demonstrates the profiling of the Eclipse IDE.  To profile another instance of the Eclipse workbook application that resides in your workbench, select "Profile" from the Profile drop down menu (see Figure 4). This opens the profile launch configuration window.



Figure 4 - Profile Drop Down Menu

 
Perform the following steps:

  1. Create a new launch item of type "Eclipse Application".
  2. Select the "Monitor" tab as shown in Figure 5.



    Figure 5 - The Profile Launch Configuration
     
  3. Click on the "Java Profiling with Instrumentation" data collector.
  4. Click on Edit options to set any desired filter.
  5. Select "Execution Time Anlysis" under "Java Profiling with Instrumentation" and select "Edit Options".
  6. Select the option "Show Execution Flow Graphical Details".
  7. Click on the Profile button to launch the application in Profile mode.
  8. Following the successful launch of the application you will see the process and the agent appear under the "Profiling Monitor" view.
  9. Right click the agent that appears under the Profiling Monitor view to get a listing of the available views.  Figure 6 shows an Execution Statistics display.



Figure 6 - The Execution Statistics Window
 

Memory Profile of an Eclipse Application

To perform a memory (Heap) profile of the Eclipse workbook application, again select "Profile" from the Profile drop down menu (see Figure 5).

 
Perform the following steps:

  1. Select the "Monitor" tab as shown in Figure 5.
  2. Click on the "Java Profiling with Instrumentation" data collector.
  3. Click on Edit options to set any desired filter.
  4. Select "Memory Analysis" under "Java Profiling with Instrumentation" (see Figure 7).



    Figure 7 - Select Memory Analysis
     
  5. Following the successful launch of the application you will see the process and the agent appear under the "Profiling Monitor" view. Figure 8 shows Memory Statistics display.
     



    Figure 8 - The Memory Statistics Window
     

Thread Profile of an Eclipse Application

To perform a thread profile of the Eclipse workbook application, again select "Profile" from the Profile drop down menu (see Figure 5).

Perform the following steps:

  1. Select the "Monitor" tab as shown in Figure 5.
  2. Click on the "Java Profiling with Instrumentation" data collector.
  3. Click on Edit options to set any desired filter.
  4. Select "Thread Analysis" under "Java Profiling with Instrumentation" (see Figure 9).



    Figure 9 - Select Thread Analysis
     
  5. Following the successful launch of the application you will see the process and the agent appear under the "Profiling Monitor" view. Figure 10 shows Thread Statistics display.
     



    Figure 10 - The Thread Statistics Window
     

Command Line Profiling using the New Java Profilerr

The new Java Profiler supports an off-line profiling mode.  This command line mode (also called Standalone Execution Mode) allows you to import the output of command line profiling into the Eclipse TPTP GUI for additional analysis.

In the Standalone Execution Mode, the new Java Profiler can be used as a standalone application to collect profiling data into a file. The data emitted by the Profiler complies with the XML4Profiling Java Trace format Specification. The output file can be imported to the Eclipse workbench using the import profiling file option available in TPTP.

To run the new Java Profiler in standalone mode on Windows, perform the following steps:

  1. Set TPTP_AC_HOME=<<Agent Controller Home>>

  2. Set JAVA_PROFILER_HOME=%TPTP_AC_HOME%\plugins\org.eclipse.tptp.javaprofiler

  3. Set PATH=%JAVA_PROFILER_HOME%;%PATH%;%TPTP_AC_HOME%\bin

  4. Set PATH=%PATH%;%JAVA_HOME%\bin

  5. Execute the following command:

java -agentlib:JPIBootLoader=JPIAgent:server=standalone;CGProf <<Your Application to profile>>

 

To run the new Java Profiler in standalone mode on Linux, perform the following steps:

  1. Set TPTP_AC_HOME=<<Agent Controller Home>>
  2. Set JAVA_PROFILER_HOME=%TPTP_AC_HOME%/plugins/org.eclipse.tptp.javaprofiler
  3. Add the following directories to LD_LIBRARY_PATH:

%JAVA_PROFILER_HOME%:%TPTP_AC_HOME%/lib
 

  1. Execute the following command:

java ‘-agentlib:JPIBootLoader=JPIAgent:server=standalone;CGProf’ <<Your Application to profile>>

 The profiling output will be written to a file named trace.trcxml in the current directory.

Note 

On Linux, make sure to surround the entire –agentlib argument with single quotes (as shown above). Otherwise, the Linux shell may interpret the semicolon (;) preceding CGProf as a command terminator and the Java application will not be executed.

Note 

Agent discovery functionality is not yet available in TPTP 4.3. Thus, both “enabled” and “controlled” modes cannot be used in TPTP 4.3 when the agent is launched from the command line. The user interface for discovering agents will be available in the early iterations of TPTP 4.4.

Limitations

Refer to the new Java profiler section of the Release Notes for any limitations that apply.

Feedback

Please provide feedback by creating bug requests or posting your questions on the TPTP newsgroup