Skip to content

PERF

Visit PERF Main Page for more information about this tool.

Perf Top

perf top -a to monitor process (both in userspace and kernel)

Perf Record

perf record [-e <EVENT> | --event=EVENT] [-a] — <command> [<options>]

To tracking an event, just using perf trace, e.g. perf record -e block:block_rq_issue -ag will trace event block_rq_issue with flag -a for all cpus and -g for enable call-graph. After ending recording, recorded data is stored at perf.data.

To list all pre-defined events, just call perf list. The important events are:

  • block_rq_issue is fired when when a block device I/O request is issued (disk I/O).

To investigate perf.data file, using perf report.

Perf Trace

https://pingcap.com/blog/how-to-trace-linux-system-calls-in-production-with-minimal-impact-on-performance

Tracking a process with PID

To track all systemcalls of a process (with PID), using perf trace -p <PID> -s, the result will look like:

root@vubuntu:/home/vux# perf trace -p 17529 -s

 Summary of events:

 ping (17529), 103 events, 98.1%

   syscall            calls  errors  total       min       avg       max       stddev
                                     (msec)    (msec)    (msec)    (msec)        (%)
   --------------- --------  ------ -------- --------- --------- ---------     ------
   recvmsg               23     23 21683.350     0.000   942.754  1024.033      5.97%
   sendto                22      0     2.288     0.056     0.104     0.127      4.46%
   write                  4      0     0.060     0.009     0.015     0.021     17.11%
   close                  2      0     0.004     0.002     0.002     0.002      4.20%

To recording the result, using perf trace record --call-graph dwarf -p $PID.

References

Back to top