长期总结 - Linux性能分析命令
perf [1] perf 是基于内核子系统的Linux的性能计数器,也被称为 perf_events,它提供了为所有事件进行性能分析的框架,perf 由两部分组成: 内核系统调用,用于提供对这些性能数据的访问 用户空间工具,用于提供收集,显示分析这些性能数据的用户空间程序 由于 perf 是内核的一部分,但要想使用 perf 还需要安装另外一部分,通常情况下安装的版本是Linux内核版本,如操作系统内核版本为 5.10 那么安装 linux-tool 后则为 5.10 bash 1 2 3 4 $ apt-get install linux-perf $ perf --version perf version 5.10.149 各系统下的包名与安装 Ubuntu/Debian: linux-perf | linux-tools ;apt-get install linux-perf CentOS/Fedora: perf ;yum install -y perf list - 列出可用事件描述符 使用 perf 子命令 list 可以列出所有的 perf 可测量事件 bash 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 perf list List of pre-defined events (to be used in -e): branch-instructions OR branches [Hardware event] branch-misses [Hardware event] cache-misses [Hardware event] cache-references [Hardware event] cpu-cycles OR cycles [Hardware event] instructions [Hardware event] stalled-cycles-backend OR idle-cycles-backend [Hardware event] stalled-cycles-frontend OR idle-cycles-frontend [Hardware event] alignment-faults [Software event] bpf-output [Software event] context-switches OR cs [Software event] cpu-clock [Software event] cpu-migrations OR migrations [Software event] dummy [Software event] emulation-faults [Software event] major-faults [Software event] minor-faults [Software event] page-faults OR faults [Software event] task-clock [Software event] duration_time [Tool event] L1-dcache-load-misses [Hardware cache event] L1-dcache-loads [Hardware cache event] L1-dcache-prefetches [Hardware cache event] L1-icache-load-misses [Hardware cache event] L1-icache-loads [Hardware cache event] branch-load-misses [Hardware cache event] branch-loads [Hardware cache event] dTLB-load-misses [Hardware cache event] dTLB-loads [Hardware cache event] iTLB-load-misses [Hardware cache event] iTLB-loads [Hardware cache event] list 子命令后还可以加过滤器以查看对应类型的事件,示例:...