HP-UX Floating-Point Guide

Chapter 7 169
Performance Tuning
Identifying and Removing Performance Bottlenecks
Identifying and Removing Performance
Bottlenecks
Computers are so fast that the only way to change the performance of
your program noticeably is to change something that happens many,
many times. For this reason, the first step in tuning an application for
increased performance is to identify the performance bottlenecks,
those sections of your code that collectively require the most execution
time. By concentrating on these areas, you can obtain the greatest
performance improvement for your effort.
Some programs spend a high percentage of execution time in small loops,
while seemingly long pieces of sequential code actually account for a
minor fraction of the total execution time. In such programs, the
performance bottlenecks are likely to be small subroutines that are
called frequently and small loops that execute over many iterations.
With its compilers HP provides the performance analysis tool Puma,
which can help you locate bottlenecks in programs. Puma takes samples
of the program counter, the call/return stack, and other performance
statistics of executing programs, saving the results in a data file. You can
then use Puma to display the data file in a variety of graphical formats.
See the puma(1) man page and the HP PAK Performance Analysis Tools
User’s Guide for more information.
HP-UX systems also support the two UNIX tools prof(1) and gprof(1).
Both of these tools tell you what percentage of the total running time of
your program is spent in each routine called. See the prof(1) and gprof(1)
man pages for information about these tools.
A more general system performance monitoring and diagnostic tool is the
HP GlancePlus product, which provides immediate performance
information about your computer system. It lets you easily examine
system activities, identify and resolve performance bottlenecks, and tune
your system for more efficient operation.
After you have identified the bottlenecks in your program, the next step
is to figure out why the bottlenecks exist and, if possible, to remove them.
The following sections apply to all code, but the emphasis is on