Este contenido no está disponible en el idioma seleccionado.
5.2. OProfile
OProfile is a low overhead, system-wide performance monitoring tool provided by the oprofile package. 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 second-level cache requests, and the number of hardware interrupts received. OProfile is also able to profile applications that run in a Java Virtual Machine (JVM).
The following is a selection of the tools provided by OProfile. Note that the legacy
opcontrol tool and the new operf tool are mutually exclusive.
- ophelp
- Displays available events for the system’s processor along with a brief description of each.
- operf
- Intended to replace
opcontrol. Theoperftool uses the Linux Performance Events subsystem, allowing you to target your 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. Unlikeopcontrol, no initial setup is required, and it can be used without the root privileges unless the--system-wideoption is in use. - 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 an annotated source for an executable if the application was compiled with debugging symbols.
- opreport
- Retrieves profile data.
- opcontrol
- This tool is used to start and stop the OProfile daemon (
oprofiled) and configure a profile session. - oprofiled
- Runs as a daemon to periodically write sample data to disk.
Legacy mode (
opcontrol, oprofiled, and post-processing tools) remains available, but it is no longer the recommended profiling method. For a detailed description of the legacy mode, see the Configuring OProfile Using Legacy Mode chapter in the System Administrator's Guide.
5.2.1. Using OProfile Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
operf is the recommended tool for collecting profiling data. The tool does not require any initial configuration, and all options are passed to it on the command line. Unlike the legacy opcontrol tool, operf can run without root privileges. See the Using operf chapter in the System Administrator's Guide for detailed instructions on how to use the operf tool.
Example 5.1. Using operf to Profile a Java Program
In the following example, the
operf tool is used to collect profiling data from a Java (JIT) program, and the opreport tool is then used to output per-symbol data.
- Install the demonstration Java program used in this example. It is a part of the java-1.8.0-openjdk-demo package, which is included in the Optional channel. See Enabling Supplementary and Optional Repositories for instructions on how to use the Optional channel. When the Optional channel is enabled, install the package:
yum install java-1.8.0-openjdk-demo
~]# yum install java-1.8.0-openjdk-demoCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Install the oprofile-jit package for OProfile to be able to collect profiling data from Java programs:
yum install oprofile-jit
~]# yum install oprofile-jitCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a directory for OProfile data:
mkdir ~/oprofile_data
~]$ mkdir ~/oprofile_dataCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Change into the directory with the demonstration program:
cd /usr/lib/jvm/java-1.8.0-openjdk/demo/applets/MoleculeViewer/
~]$ cd /usr/lib/jvm/java-1.8.0-openjdk/demo/applets/MoleculeViewer/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the profiling:
operf -d ~/oprofile_data appletviewer \ -J"-agentpath:/usr/lib64/oprofile/libjvmti_oprofile.so" example2.html
~]$ operf -d ~/oprofile_data appletviewer \ -J"-agentpath:/usr/lib64/oprofile/libjvmti_oprofile.so" example2.htmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Change into the home directory and analyze the collected data:
cd
~]$ cdCopy to Clipboard Copied! Toggle word wrap Toggle overflow opreport --symbols --threshold 0.5
~]$ opreport --symbols --threshold 0.5Copy to Clipboard Copied! Toggle word wrap Toggle overflow A sample output may look like the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow