linux 效能調優工具perf + 火焰圖 常用命令
本文是從本人筆記直接搬運過來,將就著看
perf效能分析:
生成火焰圖(執行1-4步驟):
1、perf record -e cpu-clock -g -p pid (perf record -F 99 -g -p pid 99HZ取樣)
-g 選項是告訴perf record額外記錄函式的呼叫關係
-e cpu-clock 指perf record監控的指標為cpu週期
-p 指定需要record的程式pid
perf report -i perf.data
-i 指定要檢視的檔案
2、perf script -i perf.data &> perf.unfold
用perf script工具對perf.data進行解析
3、./stackcollapse-perf.pl perf.unfold &> perf.folded
將perf.unfold中的符號進行摺疊
4、./flamegraph.pl perf.folded > perf.svg
最後生成svg圖
1、統計事件,stat:statistics
# CPU counter statistics for the specified command:
perf stat command
# Detailed CPU counter statistics (includes extras) for the specified command:
perf stat -d command
# CPU counter statistics for the specified PID, until Ctrl-C:
perf stat -p PID
# CPU counter statistics for the entire system, for 5 seconds:
perf stat -a sleep 5
# Various basic CPU statistics, system wide, for 10 seconds:
perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles -a sleep 10
2、剖析 Profiling
# Sample on-CPU functions for the specified command, at 99 Hertz:
perf record -F 99 command
# Sample on-CPU functions for the specified PID, at 99 Hertz, until Ctrl-C:
perf record -F 99 -p PID
# Sample on-CPU functions for the specified PID, at 99 Hertz, for 10 seconds:
perf record -F 99 -p PID sleep 10
# Sample CPU stack traces (via frame pointers) for the specified PID, at 99 Hertz, for 10 seconds:
perf record -F 99 -p PID -g -- sleep 10
常用引數
-e:Select the PMU event.
-a:System-wide collection from all CPUs.
-p:Record events on existing process ID (comma separated list).
-A:Append to the output file to do incremental profiling.
-f:Overwrite existing data file.
-o:Output file name.
-g:Do call-graph (stack chain/backtrace) recording.
-C:Collect samples only on the list of CPUs provided.
3、Static Tracing
# Trace new processes, until Ctrl-C:
perf record -e sched:sched_process_exec -a
# Trace all context-switches, until Ctrl-C:
perf record -e context-switches -a
# Trace context-switches via sched tracepoint, until Ctrl-C:
perf record -e sched:sched_switch -a
# Trace all context-switches with stack traces, until Ctrl-C:
perf record -e context-switches -ag
# Trace all context-switches with stack traces, for 10 seconds:
perf record -e context-switches -ag -- sleep 10
4、Dynamic Tracing
# Add a tracepoint for the kernel tcp_sendmsg() function entry ("--add" is optional):
perf probe --add tcp_sendmsg
# Remove the tcp_sendmsg() tracepoint (or use "--del"):
perf probe -d tcp_sendmsg
# Add a tracepoint for the kernel tcp_sendmsg() function return:
perf probe 'tcp_sendmsg%return'
# Show available variables for the kernel tcp_sendmsg() function (needs debuginfo):
perf probe -V tcp_sendmsg
# Show available variables for the kernel tcp_sendmsg() function, plus external vars (needs debuginfo):
perf probe -V tcp_sendmsg --externs
5、Mixed
# Sample stacks at 99 Hertz, and, context switches:
perf record -F99 -e cpu-clock -e cs -a -g
# Sample stacks to 2 levels deep, and, context switch stacks to 5 levels (needs 4.8):
perf record -F99 -e cpu-clock/max-stack=2/ -e cs/max-stack=5/ -a -g
6、Reporting
# Show perf.data in an ncurses browser (TUI) if possible:
perf report
# Show perf.data with a column for sample count:
perf report -n
# Show perf.data as a text report, with data coalesced and percentages:
perf report --stdio
# Report, with stacks in folded format: one line per stack (needs 4.4):
perf report --stdio -n -g folded
# List all events from perf.data:
perf script
# List all perf.data events, with data header (newer kernels; was previously default):
perf script --header
相關文章
- 效能工具perf的用法以及如何繪製效能火焰圖
- perf及火焰圖的使用,效能分析
- go效能調優之火焰圖Go
- perf/Simpleperf 生成火焰圖
- Linux下用perf生成火焰圖方法Linux
- linux效能分析工具之火焰圖Linux
- perf 的資料用火焰圖顯示
- 程式設計師精進之路:效能調優利器--火焰圖程式設計師
- Linux程式效能分析和火焰圖Linux
- perf效能分析工具使用分享
- Linux工具效能調優系列二:buffer和cacheLinux
- Linux火焰圖效能分析文章及視訊演示Linux
- linux調優效能命令Linux
- 如何讀懂火焰圖?+ 例項講解程式效能優化優化
- visualvm 效能調優工具LVM
- MongoDB的效能調優工具 -- DexMongoDB
- 轉:Exp/Imp工具效能調優
- Flame Graph 火焰圖分析 Java 效能Java
- linux 效能調優引數Linux
- golang 效能調優分析工具 pprof (上)Golang
- golang 效能調優分析工具 pprof(下)Golang
- Android效能調優工具之 TraceViewAndroidView
- JAVA效能分析之使用火焰圖Java
- Linux系統效能調優之效能分析Linux
- 宋寶華:火焰圖 全域性視野的 Linux 效能剖析Linux
- Linux效能調優命令之freeLinux
- Linux系統效能調優技巧Linux
- JVM效能調優,記憶體分析工具JVM記憶體
- openresty使用火焰圖排查效能問題REST
- 系統級效能分析工具perf的介紹與使用
- 如何利用工具提高React頁面渲染效能之PerfReact
- (1)Linux效能調優之Linux程式管理Linux
- Linux效能及調優指南:程式管理Linux
- Android系統效能調優工具介紹Android
- Oracle資料庫 Exp/Imp工具效能調優Oracle資料庫
- Spark 效能調優--資源調優Spark
- Spark 效能調優--Shuffle調優 SortShuffleManagerSpark
- 網路效能測試-perf