This tutorial explains how
to profile a Java code running with WebSphere 3.5.
In this document, <WebSphere> is the directory where WebSphere
3.5 has been installed (ex: c:\WebSphere\AppServer) and <OptItDir>
is the directory where OptimizeIt has been installed. (ex: c:\OptimizeItDemo\OptimizeIt40D)
1) Configuring WebSphere 3.5 for OptimizeIt
-
Copy the libraries auditjni.dll and oii.dll from the <OptItDir>\lib
directory to the <WebSphereDir>\bin directory
-
Start the WebSphere Administrative Console
-
Select the node of the Application Server you want to profile with. In
the General tab, enter the following parameters in the "Command line arguments"
section (as shown in the image below):
-Xrunoii -Djava.compiler=NONE
Then click the Apply button.
-
Select the node of a Web Application under the Servlet Engine of the Application
Server that you want to profile. Right click that node and select "Create/Servlet"
under the pop-up menu, as shown below:
-
Enter OptimizeIt in the "Servlet Name" and "Servlet Class Name" sections
as shown below, then click OK:
-
With the Web Application still selected, click the Advanced tab. In the
Classpath section, add <OptItDir>\lib\servlet and <OptItDir>\lib\optit.jar
as shown below:
Once you have set the Classpath, click on the Apply button. If the
server is not running, the section "Classpath in Use" should be updated
with the new paths. If the server is running, the "Classpath in Use" will
be updated when you restart the server.
Note: in order to add the <OptItDir>\lib\servlet, do not
use the "..." button (browse button). This button only allows to add files
(jar or zip files) and not directory. Just click an empty line in the Classpath
section and type the path directly.
-
Start the Application server (or restart if it is already started). In
order to do that, select the Application Server node, then click the start
button on the Administrative Console tool bar.
2) Starting the OptimizeIt servlet
The OptimizeIt servlet allows you to start OptimizeIt profiler in the virtual
machine of the Application Server of WebSphere. Once the profiler runs
in the virtual machine of the Application Server, you can attach to the
Application Server from OptimizeIt.
-
Invoke the servlet from a web browser. (ex: http://localhost/servlet/OptimizeIt).
-
In the HTML page that the servlet provides, change the port number if necessary.
-
Select the "Disable memory profiler" option if you only want to focus on
CPU usage.
-
Select "Enable OptimizeIt's audit system API" if your code enables/disables
the profiler by using OptimizeIt's audit system API
-
Press the "Start OptimizeIt Audit System" button to start the profiler.
Once this operation is done, you should see a message in your web browser
indicating that OptimizeIt's audit system is running.
3) Attaching from OptimizeIt
Now that the Application Server is running with OptimizeIt profiler, you
can start OptimizeIt and attach to the virtual machine.
-
Start OptimizeIt from the Start menu.
-
Close the Edit Settings panel by pressing the OK button.
-
From the Program menu, select Attach.
-
Change the port number and the hostname if necessary.
-
Press the Attach button.
Note: OptimizeIt does not have a "detach" function. If you press the stop
button in OptimizeIt, the Application Server exits and automatically restarts.
After doing this, you need to invoke the OptimizeIt servlet to restart
the profiler.
4) Filtering resources used by WebSphere
OptimizeIt provides filters for filtering resources used by WebSphere.
In order to use filters, you must create an OptimizeIt setting for the
profiling session, turn on the WebSphere filter, and then attach
by using the Attach now button or pressing the play button.
-
Start OptimizeIt's audit system by using OptimizeIt's
servlet.
-
Start OptimizeIt from the Start menu.
-
Close the settings editor by pressing OK.
-
From the File menu, select New
-
In the Edit Settings panel select Remote
Application in the Program type part.
-
Change the hostname or the port number if necessary.
-
Switch to the Filters section by clicking the
Filters
tab.
-
In the table, find the line with the name IBM
WebSphere.
-
If you want to ignore CPU or time consumed by
WebSphere, check the Ignore CPU usage column on that line.
-
If you want to ignore object allocations performed
by WebSphere, check the Ignore Memory usage column on that line.
-
Press the Attach now button.
Note: OptimizeIt settings can be saved for subsequent usage. This is done
by using the save menu.
5) Starting OptimizeIt profiler from your Java code
While the OptimizeIt servlet is convenient to start profiling quickly,
you may want to automatically start OptimizeIt profiler with one of your
servlet. That way, you don't have to invoke the OptimizeIt servlet to start
the audit system before testing your servlets.
Starting OptimizeIt profiler can be easily done by using OptimizeIt's
API. OptimizeIt's API is documented in OptimizeIt user manual, chapter
9. The following code demonstrates how to start the profiler from your
servlet:
import intuitive.audit.Audit;
...
static boolean isProfilerStarted = false;
if(!isProfilerStarted) {
/* Start OptimizeIt's profiler */
Audit.start(1470, Audit.PROFILERS_ALWAYS_ENABLED);
isProfilerStarted = true;
}
...
Note: you will need to add <OptItDir>\lib\optit.jar
to your CLASSPATH to compile this code
Once OptimizeIt's profiler is running, you can start OptimizeIt and
attach to WebSphere.
Copyright (c) 1997, 1998, 1999, 2000, 2001 Intuitive
Systems Inc. All rights reserved. Specifications subject to change without
notice.
OptimizeIt is a trademark of Intuitive Systems, Inc.
Java and all Java-based trademarks and logos are trademarks
or registered trademarks of Sun Microsystems, Inc. All other brand names
and products are trademarks or registered trademarks of their respective
holders.