Product SiteDocumentation Site

Chapter 19. OProfile

19.1. Overview of Tools
19.2. Configuring OProfile
19.2.1. Specifying the Kernel
19.2.2. Setting Events to Monitor
19.2.3. Separating Kernel and User-space Profiles
19.3. Starting and Stopping OProfile
19.4. Saving Data
19.5. Analyzing the Data
19.5.1. Using opreport
19.5.2. Using opreport on a Single Executable
19.5.3. Getting more detailed output on the modules
19.5.4. Using opannotate
19.6. Understanding /dev/oprofile/
19.7. Example Usage
19.8. OProfile Support for Java
19.8.1. Profiling Java Code
19.9. Graphical Interface
19.10. OProfile and SystemTap
19.11. Additional Resources
19.11.1. Installed Docs
19.11.2. Useful Websites
OProfile is a low overhead, system-wide performance monitoring tool. It uses the performance monitoring hardware on the processor to retrieve information about the kernel and executables on the system, such as when memory is referenced, the number of L2 cache requests, and the number of hardware interrupts received. On a Fedora system, the oprofile package must be installed to use this tool.
Many processors include dedicated performance monitoring hardware. This hardware makes it possible to detect when certain events happen (such as the requested data not being in cache). The hardware normally takes the form of one or more counters that are incremented each time an event takes place. When the counter value, essentially rolls over, an interrupt is generated, making it possible to control the amount of detail (and therefore, overhead) produced by performance monitoring.
OProfile uses this hardware (or a timer-based substitute in cases where performance monitoring hardware is not present) to collect samples of performance-related data each time a counter generates an interrupt. These samples are periodically written out to disk; later, the data contained in these samples can then be used to generate reports on system-level and application-level performance.
OProfile is a useful tool, but be aware of some limitations when using it:

19.1. Overview of Tools

Table 19.1, “OProfile Commands” provides a brief overview of the tools provided with the oprofile package.

Table 19.1. OProfile Commands

Command Description
ophelp
Displays available events for the system's processor along with a brief description of each.
opimport
Converts sample database files from a foreign binary format to the native format for the system. Only use this option when analyzing a sample database from a different architecture.
opannotate Creates annotated source for an executable if the application was compiled with debugging symbols. See Section 19.5.4, “Using opannotate for details.
opcontrol
Configures what data is collected. See Section 19.2, “Configuring OProfile” for details.
opreport
Retrieves profile data. See Section 19.5.1, “Using opreport for details.
oprofiled
Runs as a daemon to periodically write sample data to disk.