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) is available at http://java.sun.com/j2se/1.5.0/docs/guide/management/index.html.
For information on how to use the NetBeans profiler, see http://www.netbeans.org and http://blogs.sun.com/roller/page/bhavani?entry=analyzing_the_performance_of_java.
The Heap and CPU Profiling Agent (HPROF) is a simple profiler agent shipped with the Java 2 SDK. It is a dynamically linked library that interacts with the Java Virtual Machine Profiler Interface (JVMPI) and writes out profiling information either to a file or to a socket in ASCII or binary format.
HPROF can monitor CPU usage, heap allocation statistics, and 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.5.0/docs/guide/jvmpi/jvmpi.html#hprof.
After HPROF is enabled using the following instructions, its libraries are loaded into the server process.
Using the Admin Console, select the Application Server component, the JVM Settings tab, and the Profiler tab.
Edit the following fields:
Profiler Name – hprof
Profiler Enabled – true
Classpath – (leave blank)
JVM Option – Select Add, type the HPROF JVM option in the Value field, then check its box. The syntax of the HPROF JVM option is as follows:
-Xrunhprof[:help]|[:param=value,param2=value2, ...] |
Here is an example of params you can use:
-Xrunhprof:file=log.txt,thread=y,depth=3 |
The file parameter determines where the stack dump is written.
Using help lists parameters 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 |
Do not use help in the JVM Option field. This parameter prints text to the standard output and then exits.
The help output refers to the parameters as options, but they are not the same thing as JVM options.
Restart the Application Server.
This writes an HPROF stack dump to the file you specified using the file HPROF parameter.
You can purchase Optimizeit from Borland at http://www.borland.com/optimizeit.
After Optimizeit is enabled using the following instructions, its libraries are loaded into the server process.
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.
Configure the Application Server using the Admin Console:
Select the Application Server component, the JVM Settings tab, and the Profiler tab.
Edit the following fields:
Profiler Name – optimizeit
Profiler Enabled – true
Classpath – Optimizeit-dir/lib/optit.jar
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 |
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; };
Restart the Application Server.
When the server starts up with this configuration, you can attach the profiler.
For further details, see the Optimizeit documentation.
If any of the configuration options are missing or incorrect, the profiler might experience problems that affect the performance of the Application Server.
Information about Introscope® from Wily Technology is available at http://www.wilytech.com/solutions/products/Introscope.html.
After Introscope is installed using the following instructions, its libraries are loaded into the server process.
Using the Admin Console, select the Application Server component, the JVM Settings tab, and the Profiler tab.
Edit the following fields before clicking Save:
Name – wily
Enabled – true
Classpath – Wily-dir/ProbeBuilder.jar:Wily-dir/Agent.jar
Native Library Path – (leave blank)
JVM Option – (leave blank)
When the server starts up with this configuration, you can attach the profiler.
For further details, see the Introscope documentation.
If any of the configuration options are missing or incorrect, the profiler might experience problems that affect the performance of the Application Server.
Information about JProbeTM from Sitraka is available at http://www.quest.com/jprobe/.
After JProbe is installed using the following instructions, its libraries are loaded into the server process.
Install JProbe 3.0.1.1.
For details, see the JProbe documentation.
Configure Application Server using the Admin Console:
Select the Application Server component, the JVM Settings tab, and the Profiler tab.
Edit the following fields before selecting Save and restarting the server:
Profiler Name – jprobe
Profiler Enabled – true
Classpath – (leave blank)
JVM Option – For each of these options, select Add, type the option in the Value field, then check its box
-Xbootclasspath/p:JProbe-dir/profiler/jpagent.jar
-Xrunjprobeagent
-Xnoclassgc
If any of the configuration options are missing or incorrect, the profiler might experience problems that affect the performance of the Application Server.
When the server starts up with this configuration, you can attach the profiler.
Set the following environment variable:
JPROBE_ARGS_0=-jp_input=JPL-file-path |
See Step 6 for instructions on how to create the JPL file.
Start the server instance.
Launch the jpprofiler and attach to Remote Session. The default port is 4444.
Create the JPL file using the JProbe Launch Pad. Here are the required settings:
Select Server Side for the type of application.
On the Program tab, provide the following details:
Target Server – other-server
Server home Directory – install-dir
Server class File – com.sun.enterprise.server.J2EERunner
Working Directory – install-dir
Classpath – install-dir/lib/appserv-rt.jar
Source File Path – source-code-dir (in case you want to get the line level details)
Server class arguments – (optional)
Main Package – com.sun.enterprise.server
You must also set VM, Attach, and Coverage tabs appropriately. For further details, see the JProbe documentation. After you have created the JPL file, use this an input to JPROBE_ARGS_0.