Hardware heavyweight offers tool that tunes Java
- By Dan Romanchik
- July 12, 2001
One of the most serious criticisms on Java is the current implementations perform
poorly. Now, there's a tool that will help you tune that code for higher performance -- at least when your Java
code is running on an Intel processor. The tool is VTune 2.5 from Santa Clara, Calif.-based Intel Corp. -- naturally.
Santa Clara, Calif.
VTune monitors the software activity and CPU time distribution for all the software running on your system, including
the operating system, device drivers and application software. It monitors activity by interrupting the processor
at specified intervals and recording the instruction addresses of all active software on the system. For every
interrupt, VTune collects one sample and stores it in a buffer. When the buffer gets full, it suspends sampling,
writes the samples to the disk and resumes sampling until it reaches a time you specify. VTune displays the number
of samples it has acquired and asks if you would like to analyze the data.
HITTING THE HOTSPOTS
If you analyze the data, VTune will display a systemwide view of all the modules running. VTune groups all of
the JIT-compiled Java methods into a single on-screen bar on the chart. To view individual methods, you double
click on the bar, which will call up another display showing the time distribution for each method. This display
is called the 'HotSpot' report, and it very quickly shows you which portion of your code is using up the most CPU
|Intel's Vtune displays the HotSpot report to quickly uncover portions of Java code using up CPU
Double-clicking on one of the bars in the Hotspot report will display the corresponding source code. The display
will contain the source code for the entire module. The source code for the hotspot will be highlighted. You can
invoke VTune's Code Coach by double-clicking on the highlighted code. The Coach will analyze the code and offer
suggestions on how to change the source code so that it runs more quickly on Intel processors. In the Java program,
I created, the code
for (i=0; I<3000; i++)
for (j=0; j<12000; j++)
y[i] += x[i]/s
was a hotspot. When I invoked the Code Coach, it suggested that the program should compute the reciprocal of
s outside of the loop and do a multiply instead of a division inside the loop. Since multiplies are faster than
divides this should speed up the program. Another useful feature of VTune for Java programmers is call graphing.
The call graph window shows:
- every thread that was created;
- parent methods called while a thread
- child methods called by the parent
- the number of times a method was called;
- the amount of time spent in a method;
- the total time spent in a method and
the child methods it called.
The methods are instrumented, slowing down execution significantly.
Before you rush out and buy VTune, you should be aware that your Java development package must support VTune
analysis. When I first installed VTune, I planned to use it with version 1.0 of Symantec's Visual Café,
but before I could use VTune, I had to upgrade to version 2.0. And even after installing version 2.0, I had to
download an even later version of the Symantec JIT compiler before I could analyze a Java program with VTune. Most
of the other vendors selling professional-level software-development packages already support VTune or plan to
support it in the future, including Microsoft, Netscape, SuperCede, Borland and Novell. You can use VTune if you
are programming in other languages. Support for Java is what's new in version 2.5, but VTune will also analyze
C and Fortran programs and advise you on how to optimize the high-level code.
Dan Romanchik is an engineering manager turned writer and Web developer. His current passion is amateur radio. You can read his amateur radio blog at www.blurty.com/~kb6nu.