Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Developer's Guide

Profiling

You can use a profiler to perform remote profiling on the Application Server to discover bottlenecks in server-side performance. This section describes how to configure these profilers for use with the Application Server:

Information about comprehensive monitoring and management support in the JavaTM 2 Platform, Standard Edition (J2SETM platform) version 5.0 is available at http://java.sun.com/j2se/1.5.0/docs/guide/management/index.html.

The HPROF Profiler

HPROF is a simple profiler agent shipped with the Java 2 SDK. It is a dynamically linked library that interacts with the JVMPI and writes out profiling information either to a file or to a socket in ASCII or binary format.

HPROF can present CPU usage, heap allocation statistics, and monitor contention profiles. In addition, it can also report complete heap dumps and states of all the monitors and threads in the Java virtual machine. For more details on the HPROF profiler, see the JDK documentation at http://java.sun.com/j2se/1.4.2/docs/guide/jvmpi/jvmpi.html#hprof.

Once HPROF is enabled using the following instructions, its libraries are loaded into the server process.

ProcedureTo use HPROF profiling on UNIX

  1. Configure the Application Server using the Administration Console:

    1. Select the JVM Settings component under the relevant configuration, then select the Profiler tab.

    2. Edit the following fields:

      • Profiler Name: hprof

      • Profiler Enabled: true

      • Classpath: (leave blank)

      • Native Library Path: (leave blank)

      • JVM Option: For each of these options, select Add, type the option in the Value field, then check its box:

        -Xrunhprof:file=log.txt,options

        Here is an example of options you can use:


        -Xrunhprof:file=log.txt,thread=y,depth=3

        The file option determines where the stack dump is written in Step 2.

        The syntax of HPROF options is as follows:


        -Xrunhprof[:help]|[:option=value,option2=value2, ...]

        Using help lists options that can be passed to HPROF. The output is as follows:


        Hprof usage: -Xrunhprof[:help]|[:<option>=<value>, ...]
        
        Option Name and Value   Description             Default
        ---------------------   -----------             -------
        heap=dump|sites|all     heap profiling          all
        cpu=samples|old         CPU usage               off
        format=a|b              ascii or binary output  a
        file=<file>             write data to file      java.hprof
        							   (.txt for ascii)
        net=<host>:<port>       send data over a socket write to file
        depth=<size>            stack trace depth       4
        cutoff=<value>          output cutoff point     0.0001
        lineno=y|n              line number in traces?  y
        thread=y|n              thread in traces?       n
        doe=y|n                 dump on exit?           y
  2. Restart the Application Server. This writes an HPROF stack dump to the file you specified using the file HPROF option in Step 1.

The Optimizeit Profiler

You can purchase OptimizeitTM from Borland at http://www.borland.com/optimizeit.

Once Optimizeit is enabled using the following instructions, its libraries are loaded into the server process.

ProcedureTo enable remote profiling with Optimizeit

  1. Configure your operating system:

    • On Solaris, add Optimizeit-dir/lib to the LD_LIBRARY_PATH environment variable.

    • On Windows, add Optimizeit-dir/lib to the PATH environment variable.

  2. Configure the Application Server using the Administration Console:

    1. Select the JVM Settings component under the relevant configuration, then select the Profiler tab.

    2. Edit the following fields:

      • Profiler Name: optimizeit

      • Profiler Enabled: true

      • Classpath: Optimizeit-dir/lib/optit.jar

      • Native Library Path: Optimizeit-dir/lib

      • JVM Option: For each of these options, select Add, type the option in the Value field, then check its box:


        -DOPTITHOME=Optimizeit-dir  -Xrunpri:startAudit=t 
        -Xbootclasspath/p:/Optimizeit-dir/lib/oibcp.jar
  3. In addition, you might have to set the following in your server.policy file.

    For more information about the server.policy file, see The server.policy File

    grant codeBase "file:Optimizeit-dir/lib/optit.jar" {
    	permission java.security.AllPermission;
    };
  4. Restart the Application Server.

    When the server starts up with this configuration, you can attach the profiler.

See Also

For further details, see the Optimizeit documentation.

Troubleshooting

If any of the configuration options are missing or incorrect, the profiler might experience problems that affect the performance of the Application Server.