linux 下性能分析 ---bootchart【轉】

轉自:https://winddoing.github.io/post/5f89ded7.html

BootChart 是一個用於 linux 啓動過程性能分析的開源軟件工具,它可以在內核裝載後就開始運行,記錄各個程序啓動佔用的時間、CPU 以及硬盤讀寫,直到系統啓動完成爲止。進入系統後,bootchart 可以將啓動時記錄下的內容生成多種格式(PNG,SVG 或者 EPS)的圖形報表,以便分析。

一般應用運行分析

用 perf 錄製系統的 sched 情況

1
2
3
$sudo perf sched record -a
^C[ perf record: Woken up 5 times to write data ]
[ perf record: Captured and wrote 11.284 MB perf.data (87520 samples) ]
 

生成 timechart

1
2
$sudo perf timechart
Written 24.6 seconds of trace to output.svg.
 

使用 Firefox 瀏覽器查看生成結果:

bootchart_sample

bootchart_sample

 

系統啓動時間的分析

bootchart

ubuntu20.04 中不適用,不過使用 systemd-analyze 可以查看開機時間和耗時部分

1
sudo apt install bootchart pybootchartgui
 

~ 在 ubuntu20.04 系統安裝後 (其他系統安裝也可),下次系統啓動時生成一個系統啓動時的各個組件啓動所花的時間的記錄的圖表,此圖表位於:/var/log/bootchart 文件夾下。默認格式爲.png 格式~

initcall_debug 內核啓動圖

這個方法多用於嵌入式系統中,在內核命令行中添加 initcall_debug 參數,可以在 dmesg 日誌中打印出每個函數調用的時間點

  1. 將 dmesg 的日誌保存到 boot.log 中
  2. 運行內核源碼中自帶的 scripts/bootgraph.pl 腳本生成啓動圖 (矢量圖)
    1
    scripts/bootgraph.pl boot.log > boot.svg
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章