I want to use perf
and FlameGraph to generate a cpu usage flamegraph of my golang program.
$ go build -gcflags=all="-N -l" -o my_program ./*.go # Compile with debug info.
$ ./my_program
$ perf record -e cycles -F 100 --call-graph dwarf,65528 -o ~/my.data -p <my_program pid>
$ perf script -i ~/my.data | ~/FlameGraph/stackcollapse-perf.pl | ~/FlameGraph/flamegraph.pl > ~/perf.svg
In the flamegraph, all the functions in my program has the name [my_program]
, and I can’t see their real names. Here are some outputs of perf report -i ~/my.data
:
Warning:
Processed 3832 events and lost 1 chunks!
Check IO/CPU overload!
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 219 of event 'cycles'
# Event count (approx.): 763795261
#
# Children Self Command Shared Object Symbol
# ........ ........ ............... ................... ..........................................................................
...............................................................................................................................
#
54.10% 10.45% cfs-server-debu cfs-server-debug [.] _start
|
|--43.65%--_start
| |
......
| |
| --3.84%--_start
|
--3.64%--0x188a20
0x703797
0x7075a4
0x707a88
0x6fe2f0
0x257273
0x258e8b
0x266945
0x2673ec
0x260fcb
0x2675c6
0x210c04
0x217b90
0x218b24
_start
_start
_start
......
I searched it and asked chatgpt, but I still have not found an answer for this question.
Thanks for your time!
New contributor
Yu-Ang Cao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.