Chapter 13. OProfile

OProfile is a low overhead, system-wide profiler that 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 level 2 cache (L2) requests, and the number of hardware interrupts received. It consists of a configuration utility, a daemon for collecting data, and a number of tools that can be used to transform the data into a human-readable form. For a complete list of tools that are distributed with the Red Hat Developer Toolset version of OProfile, see Table 13.1, “Tools Distributed with OProfile for Red Hat Developer Toolset”.
OProfile profiles an application without adding any instrumentation by recording the details of every nth event. This allows it to consume fewer resources than Valgrind, but it also causes its samples to be less precise. Unlike Valgrind, which only collects data for a single process and its children in user-space, OProfile is well suited to collect system-wide data on both user-space and kernel-space processes, and requires root privileges to run.
Red Hat Developer Toolset is distributed with OProfile 1.1.0.

Table 13.1. Tools Distributed with OProfile for Red Hat Developer Toolset

Name Description
oprofiled The OProfile daemon that collects profiling data.
operf Intended to replace the deprecated opcontrol tool. The operf tool uses the Linux Performance Events subsystem, allowing users to target their profiling more precisely, as a single process or system-wide, and allowing OProfile to co-exist better with other tools using the performance monitoring hardware on your system. Unlike opcontrol, no initial setup is required, and it can be used without the root privileges unless the --system-wide option is in use.
opannotate Generates an annotated source file or assembly listing from the profiling data.
oparchive Generates a directory containing executable, debug, and sample files.
opgprof Generates a summary of a profiling session in a format compatible with gprof.
ophelp Displays a list of available events.
opimport Converts a sample database file from a foreign binary format to the native format.
opjitconv Converts a just-in-time (JIT) dump file to the Executable and Linkable Format (ELF).
opreport Generates image and symbol summaries of a profiling session.
ocount A new tool for counting the number of times particular events occur during the duration of a monitored command.

13.1. Installing OProfile

In Red Hat Developer Toolset, OProfile is provided by the devtoolset-4-oprofile package and is automatically installed with devtoolset-4-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”.