Profiling to Understand the Application

team bbl


It is a truism that the most time-consuming and frequently used sections of a program should be optimized first. Profiling tools should be used before performance tuning begins, both to discover these areas and to provide a baseline for measuring the effectiveness of the tuning that is being performed later. When profiling the application, use (and be consistent in using) realistic sizes of workload and datasets. Although you need to use some variety later in the fine-tuning process or else risk tuning to one model at the expense of others, early iterations using the same initial loads as the baseline can offer insight into successful tuning attacks.

The basic profiling tools in Linux are the p (profile) and pg (profile for gprof) options in gcc, and the prof and gprof utilities. Compiling using p or -pg causes gcc to insert instructions necessary to obtain profiling information into the object code. Running the prof command with the application allows you to then obtain the following:

  • Each procedure, ordered by descending processor activity

  • The percentage of CPU time used by each procedure

  • The execution time in seconds for all references

  • The number of times each procedure was called

  • The average time for a call to the procedure

Running the gprof command with the application gathers (among other information) the following:

  • The percentage of CPU time used by each procedure and its calling tree

  • A time breakdown for each procedure and what it calls

  • The number of times a procedure was called

  • What procedures were called by each procedure

Because gprof includes the descendents of a procedure in its timings, it is more useful for procedures calling library routines.

Although other profiling tools are available to the developer, prof and gprof are mentioned here because they are the most commonly available. Some of these alternative tools can be specialized for a specific purpose, such as parallel programming or massively multithreaded applications.

After successfully profiling for optimization, you are ready to begin tuning. Modern compilers offer many optional optimization features. gcc, for example, offers more than 60 options related to performance optimization. The next section discusses basic steps and compilers as tuning tools.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net