perf +火焰图使用
生活随笔
收集整理的這篇文章主要介紹了
perf +火焰图使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
以mysqld進程為例:
[root@VM-90-225-centos ~]# ps -ef | grep mysqld root 9808 9621 0 19:30 pts/7 00:00:00 grep --color=auto mysqld root 16104 1 0 17:30 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/VM-90-225-centos.pid mysql 16415 16104 30 17:30 pts/0 00:37:16 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/usr/local/mysql/data/VM-90-225-centos.pid --socket=/var/lib/mysql/mysql.sock [root@VM-90-225-centos ~]# perf record -a -g -F99 -p 16415 Warning: PID/TID switch overriding SYSTEM ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.106 MB perf.data (38 samples) ]關于perf命令參數:
# -a, --all-cpus system-wide collection from all CPUs # -g, --call-graph <mode[,dump_size]> # -F, --freq <n> profile at this frequenc如果像要采樣一段時間可以使用:
perf record -a -g -F99 -p 16415 sleep 60通過上述步驟可以獲得perf.data,并保存到你執行命令的目錄下
[root@VM-90-225-centos ~]# ll total 71664 -rw-r--r-- 1 root root 17643311 Jul 15 2021 dtools drwxr-xr-x 4 root root 4096 Jul 29 2021 go drwxr-xr-x 7 59314 users 4096 Dec 21 16:15 iGeneral_client_3 -rw-r--r-- 1 root root 55552131 Jan 27 2021 iGeneral_client_3.tgz -rw------- 1 root root 165944 Feb 24 19:31 perf.data drwxr--r-- 4 root root 4096 Jul 29 2021 polaris drwxr-xr-x 22 root root 4096 Jul 29 2021 protobuf然后繼續:
[root@VM-90-225-centos ~]# perf script > perf.script [root@VM-90-225-centos ~]# ls -l perf.script -rw-r--r-- 1 root root 46126 Feb 24 19:32 perf.script然后需要用到FlameGraph的插件,這里手動去下一下:
git clone https://editor.csdn.net/md?not_checkout=1&articleId=123119285這里我把它保存到/home/hanhan/目錄下
然后回到script的目錄:
執行:
然后把svg圖下載到本地用瀏覽器打開
總結
以上是生活随笔為你收集整理的perf +火焰图使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一吨沙多少钱啊?
- 下一篇: dnf男弹药魔法流加点 配上图谢谢