Read and parse perf.data

Asked
Active3 hr before
Viewed126 times

6 Answers

parse
90%

Meta Stack Overflow ,Thanks for contributing an answer to Stack Overflow!, Stack Overflow help chat ,Stack Overflow em Português

To convert perf.data file

perf script > perf.data.txt

To convert output of perf record in other file (perf record -o filename.data) use -i option:

perf script - i filename.data > filename.data.txt
   perf - script - Read perf.data(created by perf record) and display
   trace output

   This command reads the input file and displays the trace recorded.

   'perf script'
   to see a detailed trace of the workload that was
   recorded.
load more v
88%

I am recording a performance counters frm linux using the command perf record.,An example command definition that redirects service check performance data to a text file for later processing by another application is shown below:,To convert output of perf record in other file (perf record -o filename.data) use -i option:,There is builtin perf.data parser and printer in perf tool of linux tools with subcommand "script".

To convert perf.data file

perf script > perf.data.txt

To convert output of perf record in other file (perf record -o filename.data) use -i option:

perf script - i filename.data > filename.data.txt
   perf - script - Read perf.data(created by perf record) and display
   trace output

   This command reads the input file and displays the trace recorded.

   'perf script'
   to see a detailed trace of the workload that was
   recorded.
load more v
72%

perf-report - Read perf.data (created by perf record) and display the profile ,perf-annotate (1) - Read perf.data (created by perf record) and display annotated code,perf-diff (1) - Read perf.data files and display the differential profile, This command displays the performance counter profile information recorded via perf record.

perf report [-i <file> | --input=file]
Each key has following meaning:
By
default, comm, dso and symbol keys are used.
   (i.e.--sort comm, dso, symbol)
If--branch - stack option is used, following sort keys are also
available:
   dso_from, dso_to, symbol_from, symbol_to, mispredict.
And
default sort keys are changed to comm, dso_from, symbol_from, dso_to
and symbol_to, see '--branch-stack'.
By
default, every sort keys not specified in -F will be appended
automatically.
If--mem - mode option is used, following sort keys are also available(incompatible with--branch - stack):
   symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline.
And
default sort keys are changed to local_weight, mem, sym, dso,
symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
order can be either:
   -callee: callee based call graph. -
   caller: inverted caller based call graph.
key can be:
   - function: compare on functions -
   address: compare on individual code addresses
Default: fractal, 0.5, callee,
   function.
Default: 127
"relative"
means it 's relative to filtered entries only so that the
sum of shown entries will be always 100 % .
"absolute"
means it retains
the original value before and after the filter is applied.
load more v
65%

sampling events, which writes event data to a kernel buffer, which is read at a gentle asynchronous rate by the perf command to write to the perf.data file. This file is then read by the perf report or perf script commands.,counting events in-kernel context, where a summary of counts is printed by perf. This mode does not generate a perf.data file.,perf_events is an event-oriented observability tool, which can help you solve advanced performance and troubleshooting functions. Questions that can be answered include:,Try starting by counting events using the perf stat command, to see if this is sufficient. This subcommand costs the least overhead.

Starting with a screenshot, here's perf version 3.9.3 tracing disk I/O:

# perf record - e block: block_rq_issue - ag ^
   C
# ls - l perf.data -
   rw-- -- -- - 1 root root 3458162 Jan 26 03: 03 perf.data
# perf report
   [...]
# Samples: 2 K of event 'block:block_rq_issue'
# Event count(approx.): 2216
#
# Overhead Command Shared Object Symbol
#.........................................................
#
32.13 % dd[kernel.kallsyms][k] blk_peek_request |
   -- - blk_peek_request
virtblk_request
__blk_run_queue
   |
   |
   --98.31 % --queue_unplugged |
   blk_flush_plug_list |
   |
   |
   | --91.00 % --blk_queue_bio |
   | generic_make_request |
   | submit_bio |
   | ext4_io_submit |
   | |
   |
   | | --58.71 % --ext4_bio_write_page |
   | | mpage_da_submit_io |
   | | mpage_da_map_and_submit |
   | | write_cache_pages_da |
   | | ext4_da_writepages |
   | | do_writepages |
   | | __filemap_fdatawrite_range |
   | | filemap_flush |
   | | ext4_alloc_da_blocks |
   | | ext4_release_file |
   | | __fput |
   | | ____fput |
   | | task_work_run |
   | | do_notify_resume |
   | | int_signal |
   | | close |
   | | 0x0 |
   | |
   |
   | --41.29 % --mpage_da_submit_io[...]
load more v
75%

An easier way to record tracing data is with the Linux perf command.,First, perf starts. The script subcommand's -s option indicates that an external script will be used.,Will result in a trace file that begins with the following series of events for a single task (the perf command itself):,So, these scripts come with perf, and both Python and Perl are supported languages.

$ perf script - s. / perf - script.py-- --script - arg1[...]
40%

For details of in-depth Linux/UNIX system programming training courses that I teach, look here. , HTML rendering created 2021-08-27 by Michael Kerrisk, author of The Linux Programming Interface, maintainer of the Linux man-pages project.

PERF - REPORT(1) perf Manual PERF - REPORT(1)
load more v

Other "parse-undefined" queries related to "Read and parse perf.data"