Perf data analysis using pprof

Data for the index perf tools, we can use the built-in report and script view, use for flame Figure
flamescope also very good, but if you need cross-platform analysis using a combination perf_data_converter pprof very convenient, the following
is a simple integrated use

perf_data_converter system constructed using centos

Installation perf_data_converter

The need to build tools to support bazel, some dependencies

  • Installation depends
 
yum install -y elfutils-libelf-devel
yum install -y libcap-devel
  • Code clone
git clone https://github.com/google/perf_data_converter.git
cd perf_data_converter
bazel build src:perf_to_profile
  • Configuration environment variable
    to add to the path path perf_data_converter

Generating a data perf.data

  • command
perf record 

Conversion perf.data

  • command
perf_to_profile -i perf.data -o perf-convert
  • effect
perf_to_profile -i perf.data -o perf-convert
[WARNING:src/quipper/perf_reader.cc:1036] Skipping unsupported event PERF_RECORD_CPU_MAP
[INFO:src/quipper/perf_reader.cc:1027] Number of events stored: 152820
[INFO:src/quipper/perf_parser.cc:268] Parser processed: 3418 MMAP/MMAP2 events, 593 COMM events, 724 FORK events, 169 EXIT events, 146065 SAMPLE events, 144231 of these were mapped
[INFO:src/perf_data_handler.cc:88] Using the build id found for the file name: [kernel.kallsyms], build id: 14504bc038206548e6bb85f4812ead4c3bb427f4.
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 1 /usr/lib/systemd/systemd
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 10415 /usr/lib/systemd/systemd-udevd
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 10503 /usr/libexec/pcp/bin/pmwebd
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 18404 /usr/libexec/pcp/bin/pmproxy
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 4147 /usr/lib/systemd/systemd-journald
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 6618 /usr/libexec/pcp/bin/pmcd
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 777 /usr/lib/systemd/systemd-logind;5df33705 (deleted)
[INFO:src/perf_data_handler.cc:476] guessing main for pid: 783 /usr/lib/polkit-1/polkitd
[WARNING:src/perf_data_handler.cc:349] stat: missing_callchain_mmap 150999/1287082

Use pprof analysis

  • pprof supported commands
callgrind Outputs a graph in callgrind format
comments Output all profile comments
disasm Output assembly listings annotated with samples
dot Outputs a graph in DOT format
eog Visualize graph through eog
evince Visualize graph through evince
gif Outputs a graph image in GIF format
gv Visualize graph through gv
kcachegrind Visualize report in KCachegrind
list Output annotated source for functions matching regexp
pdf Outputs a graph in PDF format
peek Output callers/callees of functions matching regexp
png Outputs a graph image in PNG format
proto Outputs the profile in compressed protobuf format
ps Outputs a graph in PS format
raw Outputs a text representation of the raw profile
svg Outputs a graph in SVG format
tags Outputs all tags in the profile
text Outputs top entries in text form
top Outputs top entries in text form
topproto Outputs top entries in compressed protobuf format
traces Outputs all profile samples in text form
tree Outputs a text rendering of call graph
web Visualize graph through web browser
weblist Display annotated source in a web browser
o/options List options and their current values
quit/exit/^D Exit pprof
  • Installation pprof
go get -u github.com/google/pprof
  • Analysis of the data generated perf
    loading perf data:
 
pprof perf-convert

Simple analysis (text):

 

 


Filtration treatment

 

 

Explanation

pprof powerful analysis golang and perf are very good tool, but also can be integrated into applications as golang package, performance analysis system is
very convenient

Reference material

https://github.com/google/perf_data_converter
https://github.com/google/pprof
https://cizixs.com/2017/09/11/profiling-golang-program/

Guess you like

Origin www.cnblogs.com/rongfengliang/p/12097184.html