环境: centos 7
一、CentOS 安装 debuginfo-install
安装debuginfo相关的包步骤如下:
1、 修改文件/etc/yum.repos.d/CentOS-Debuginfo.repo中的enabled参数,将其值修改为1
2、 使用命令:
yum install nss-softokn-debuginfo –nogpgcheck
yum install yum-utils
二、安装perf
yum install google-perftools google-perftools-devel
perf常用的命令包括:
perf list:用来查看perf所支持的性能事件,有软件的也有硬件的
命令格式:perf list [hw | sw | cache | tracepoint | event_glob]
perf stat:用于分析指定程序的性能概况。
Run a command and gather performance counter statistics.
perf stat [-e <EVENT> | --event=EVENT] [-a] <command>
perf stat [-e <EVENT> | --event=EVENT] [-a] - <command> [<options>]
perf top:对于一个指定的性能事件(默认是CPU周期),显示消耗最多的函数或指令。
System profiling tool.
Generates and displays a performance counter profile in real time.
perf top [-e <EVENT> | --event=EVENT] [<options>]
perf top主要用于实时分析各个函数在某个性能事件上的热度,能够快速的定位热点函数,包括应用程序函数、
模块函数与内核函数,甚至能够定位到热点指令。默认的性能事件为cpu cycles。
perf record:收集采样信息,并将其记录在数据文件中。随后可以通过其它工具(perf-report)对数据文件进行分析,结果类似于perf-top的
perf report:读取perf record创建的数据文件,并给出热点分析结果。
比较详细的命令参数见网页:http://blog.csdn.net/zhangskd/article/details/37902159/
三、安装调试信息
进行分析的时候,需要对应的调试符号信息,比如glibc,安装调试符号信息的命令如下:
debuginfo-install glibc
四、常用的工具: cpu的火焰图
使用火焰图分析CPU性能回退问题 https://linux.cn/article-4670-1.html
主要的原理是使用二次的采集来对比,然后生成火焰图
五、其他分析工具
linux常见分析工具: http://www.oschina.net/translate/command-line-tools-to-monitor-linux-performance?cmp&p=1
top/vmstat/lsof/tcpdump/netstat/htop/iotop/iostat/iptraf/Psacct or Acct/monit/NetHogs/iftop/Monitorix/Arpwatch/Suricata/VnStat PHP/Nagios
六、分析案件
阿里中间件团队
10+倍性能提升全过程--优酷账号绑定淘宝账号的TPS从500到5400的优化历程 http://jm.taobao.org/2017/05/04/20170504/
七、参考文档:
perf简单案例 http://blog.chinaunix.net/uid-10540984-id-3854969.html
perf常用命令行 http://blog.csdn.net/zhangskd/article/details/37902159/
使用 google-perftools 剖析程序性能瓶颈 https://www.oschina.net/question/12_14213
google-perftools 分析JAVA 堆外内存 http://blog.csdn.net/turkeyzhou/article/details/6719867
google-perftools简明使用 http://blog.csdn.net/code_my_life/article/details/51287018
监控Linux 性能的 18 个命令行工具 http://www.oschina.net/translate/command-line-tools-to-monitor-linux-performance?cmp&p=2#
Linux中iptraf命令详解 http://blog.csdn.net/quiet_girl/article/details/50777210
深入理解debuginfo http://blog.csdn.net/chinainvent/article/details/24129311?reload
Perf -- Linux下的系统性能调优工具,第 2 部分 https://www.ibm.com/developerworks/cn/linux/l-cn-perf2/
Perf -- Linux下的系统性能调优工具,第 1 部分 https://www.ibm.com/developerworks/cn/linux/l-cn-perf1/
Java火焰图在Netflix的实践 http://www.infoq.com/cn/news/2015/08/java-flamegraph
Java in Flames https://medium.com/netflix-techblog/java-in-flames-e763b3d32166