Este contenido no está disponible en el idioma seleccionado.
Chapter 23. Monitoring application performance with perf
You can use the perf tool to monitor and analyze application performance.
23.1. Attaching perf record to a running process Copiar enlaceEnlace copiado en el portapapeles!
You can attach perf record to a running process. This will instruct perf record to only sample and record performance data in the specified processes.
Prerequisites
-
You have the
perfuser space tool installed as described in Installing perf.
Procedure
Attach
perf recordto a running process:perf record -p ID1,ID2 sleep seconds
$ perf record -p ID1,ID2 sleep secondsCopy to Clipboard Copied! Toggle word wrap Toggle overflow The previous example samples and records performance data of the processes with the process ID’s
ID1andID2for a time period ofsecondsseconds as dictated by using thesleepcommand. You can also configureperfto record events in specific threads:perf record -t ID1,ID2 sleep seconds
$ perf record -t ID1,ID2 sleep secondsCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhen using the
-tflag and stipulating thread ID’s,perfdisables inheritance by default. You can enable inheritance by adding the--inheritoption.
23.2. Capturing call graph data with perf record Copiar enlaceEnlace copiado en el portapapeles!
You can configure the perf record tool so that it records which function is calling other functions in the performance profile. This helps to identify a bottleneck if several processes are calling the same function.
Prerequisites
-
You have the
perfuser space tool installed as described in Installing perf.
Procedure
Sample and record performance data with the
--call-graphoption:perf record --call-graph method command
$ perf record --call-graph method commandCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
commandwith the command you want to sample data during. If you do not specify a command, thenperf recordwill sample data until you manually stop it by pressing Ctrl+C. Replace method with one of the following unwinding methods:
fp-
Uses the frame pointer method. Depending on compiler optimization, such as with binaries built with the GCC option
--fomit-frame-pointer, this may not be able to unwind the stack. dwarf- Uses DWARF Call Frame Information to unwind the stack.
lbr- Uses the last branch record hardware on Intel processors.
-
Replace
23.3. Analyzing perf.data with perf report Copiar enlaceEnlace copiado en el portapapeles!
You can use perf report to display and analyze a perf.data file.
Prerequisites
-
You have the
perfuser space tool installed as described in Installing perf. -
There is a
perf.datafile in the current directory. -
If the
perf.datafile was created with root access, you need to runperf reportwith root access too.
Procedure
Display the contents of the
perf.datafile for further analysis:perf report
# perf reportCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command displays output similar to the following:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow