perf 简介

简介: Perf 简介 1.Perf简介 Perf是Linux kernel自带的系统性能优化工具。虽然它的版本还只是0.0.2,Perf已经显现出它强大的实力,足以与目前Linux流行的OProfile相媲美了。

Perf 简介

1.Perf简介

PerfLinux kernel自带的系统性能优化工具。虽然它的版本还只是0.0.2Perf已经显现出它强大的实力,足以与目前Linux流行的OProfile相媲美了。

Perf的优势在于与Linux Kernel的紧密结合,它可以最先应用到加入Kernelnew feature。而像OProfile, GProf等通常会慢一拍Perf的基本原理跟OProfile等类似,也是在CPUPMU registersGet/Set performance counters来获得诸如instructions executed, cache-missed suffered, branches mispredicted等信息。Linux kernel对这些registers进行了一系列抽象,所以你可以按进程,按CPU或者按counter group等不同类别来查看Sample信息。

2.使用Perf

$ perf record -f -- git gc

$ perf report --sort comm,dso,symbol | head -10

perf record相当于opcontrol --start, perf report相当于opreport.

查看所有可用的counters'perf list’

可以用以上counter的任意组合来跑测试程序。如,用以下命令来看跑hackbenchpage alloc/free的次数。

perf stat -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc ./hackbench 10

Perf可以统计N次结果的数值波动情况:perf stat --repeat 5 -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc ./hackbench 10

perf record -f -e kmem:mm_page_alloc -c 1 ./git gc查看哪个function引起了page allocations

titan:~/git> perf report

titan:~/git> perf report --sort comm,dso,symbol

同时,call-graph(函数调用图)也可以被记录下来,并且能告诉你每个函数所占用的百分比。

titan:~/git> perf record -f -g -e kmem:mm_page_alloc -c 1 ./git gc

titan:~/git> perf report -g

用以下命令查看整个系统10秒内的page allocation次数:

titan:~/git> perf stat -a -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc sleep 10

以下命令查看每隔1秒,系统page allocation的波动状况:

titan:~/git> perf stat --repeat 10 -a kmem:mm_page_alloc sleep 1

通过反汇编往往能找出是哪行代码生成的指令会引起问题。

titan:~/git> perf annotate __GI___fork

原文

http://blog.csdn.net/bluebeach/article/details/5912062

https://perf.wiki.kernel.org/index.php/Tutorial

http://whatot.github.io/pub/linux_program/perf%E7%AE%80%E4%BB%8B/

目录
相关文章
|
2月前
|
Rust 数据可视化 安全
Rust性能分析工具概览:perf、flamegraph 与其他
Rust作为一种高性能、内存安全的编程语言,在构建大型系统和微服务时备受青睐。然而,优化Rust程序的性能需要有效的工具。本文将对Rust中常用的性能分析工具进行介绍,包括perf、flamegraph等,并探讨它们如何帮助开发者定位和解决性能瓶颈。
|
机器学习/深度学习 监控 Ubuntu
perf性能分析工具使用分享
perf性能分析工具使用分享
1552 0
perf性能分析工具使用分享
|
网络协议 Linux 数据库
|
2月前
|
监控 Linux 测试技术
【 C/C++ 性能分析工具 CPU 采样分析器 perf 】掀开Linux perf性能分析的神秘面纱
【 C/C++ 性能分析工具 CPU 采样分析器 perf 】掀开Linux perf性能分析的神秘面纱
158 0
|
10月前
|
数据可视化 Linux 调度
译 | Linux perf_events Off-CPU Time Flame Graph
译 | Linux perf_events Off-CPU Time Flame Graph
74 0
|
存储 数据可视化 Linux
ChIP-seq 分析:教程简介(1)
[本课程](https://rockefelleruniversity.github.io/RU_ChIPseq/ "Source")介绍 Bioconductor 中的 ChIPseq 分析。该课程由 4 个部分组成。这将引导您完成正常 ChIPseq 分析工作流程的每个步骤。它涵盖比对、QC、`peak calling`、基因组富集测试、基序富集和差异 ChIP 分析。
255 0
|
负载均衡 Cloud Native Linux
Linux Command Perf 性能剖析
Linux Command Perf 性能剖析
Linux Command Perf 性能剖析