分析和優化Linux服務器
變得完美|運行完美|完善
該命令行工具旨在幫助您分析和優化Linux服務器以及在其上運行的軟件。無論您是系統管理員,開發人員還是性能工程師,此工具都提供全面的見解和可行的建議,以提高性能和效率。
$ wget -qO- https://github.com/intel/PerfSpect/releases/latest/download/perfspect.tgz | tar xvz
$ cd perfspect
Perfspect包括一套旨在分析和優化系統和軟件性能的命令套件。
運行perfspect -h以獲得頂級幫助。注意可用命令和選項。
Perfspect已重新設計了3.x版本。完善的先前版本需要兩個階段:
3.X設計將這兩個步驟結合在一起,將其製成用戶友好的指標。為新體驗運行perfspect metrics 。
3.x也可以使用“實時指標”,其中指標在收集時被打印到Stdout。嘗試perfspect metrics --live 。
SVR-INFO功能現在包含在Perfspect中。 SVR-INFO配置報告是通過運行perfspect report生成的。可以通過運行perfspect report --benchmark all來執行基準測試。運行perfspect flame以生成軟件火焰。並且,運行perfspect telemetry以收集系統遙測。
| 命令 | 描述 |
|---|---|
perfspect config | 修改系統配置 |
perfspect flame | 生成火焰圖 |
perfspect lock | 收集系統寬的熱點,C2C和鎖定競爭信息 |
perfspect metrics | 監視核心和無關指標 |
perfspect report | 生成配置報告 |
perfspect telemetry | 收集系統遙測 |
每個命令都有其他幫助文本,可以通過運行perfspect <command> -h來查看。
config命令提供了一種方法來查看和更改各種系統配置參數。運行perfspect config -h以查看可以修改的參數。更改系統參數時要謹慎。可以以不再操作的方式配置系統。在某些情況下,將需要重新啟動返回默認設置。
例子:
$ ./perfspect config --cores 24 --llc 2.0 --uncoremaxfreq 1.8
...
軟件火焰圖可用於診斷軟件性能瓶頸。運行perfspect flame以捕獲整個系統的軟件火焰圖。
由於系統包含越來越多的核心,分析內核鎖定頭頂和影響系統可伸縮性的潛在虛假共享可能會很有用。運行perfspect lock以收集系統寬的熱點,C2C和鎖定競爭信息。經驗豐富的績效工程師可以分析收集的信息以識別瓶頸。
metrics命令提供系統性能表徵指標。提供的指標取決於平台體系結構。
例子:
$ ./perfspect metrics --duration 30
emr ⣯ collection complete
Metric files:
/home/jharper5/dev/pt/perfspect_2024-10-10_10-58-36/emr_metrics.csv
/home/jharper5/dev/pt/perfspect_2024-10-10_10-58-36/emr_metrics_summary.csv
/home/jharper5/dev/pt/perfspect_2024-10-10_10-58-36/emr_metrics_summary.html
metrics命令支持兩種模式 - 默認和“ live”。默認模式的行為如上 - 收集指標並將其保存到文件中以進行審查。 “實時”模式以所選格式(例如,CSV,JSON)打印指標,以便在控制台中查看它們,並將其重定向到文件或可觀察性管道中。
如果不可能使用sudo並運行,則在命令行上使用--noroot標誌,例如, perfspect metrics --noroot ,並請求管理員對目標系統進行以下更改:
for i in $(find /sys/devices -name perf_event_mux_interval_ms); do echo 125 > $i; done有關廣泛的選項和示例,請參見perfspect metrics -h 。
report命令以各種格式生成系統配置報告。默認情況下,收集了所有信息類別:
$ ./perfspect report
soc-PF4W5A3V ⢿ collection complete
Report files:
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-45-40/soc-PF4W5A3V.html
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-45-40/soc-PF4W5A3V.xlsx
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-45-40/soc-PF4W5A3V.json
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-45-40/soc-PF4W5A3V.txt
可以通過提供命令行選項來收集信息子集。請注意,僅指定txt格式,它將被打印到Stdout,並寫入報告文件。
$ ./perfspect report --bios --os --format txt
BIOS
====
Vendor: Intel Corporation
Version: EGSDCRB1.SYS.1752.P05.2401050248
Release Date: 01/05/2024
Operating System
================
OS: Ubuntu 23.10
Kernel: 6.5.0-44-generic
Boot Parameters: BOOT_IMAGE=/boot/vmlinuz-6.5.0-44-generic root=UUID=e6d667af-f0b7-450b-b409-9fe2647aeb38 ro
Microcode: 0x21000230
Report files:
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-47-55/emr.txt
有關所有選項,請參見perfspect report -h 。
通過Perfspect Report命令執行的內存基準要求Intel®內存延遲檢查器應用程序。它可以從這裡下載:MLC。下載後,提取Linux可執行文件,然後將其放置在Perfspect/Tools/X86_64目錄中。
telemetry命令在指定的目標上運行遙測收集器,然後生成結果報告。默認情況下,收集了所有遙測類型。要選擇遙測類型,請提供其他命令行選項(請參閱perfspect telemetry -h )。
$ ./perfspect telemetry --duration 30
soc-PF4W5A3V ⣾ collection complete
Report files:
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-55-13/soc-PF4W5A3V_telem.html
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-55-13/soc-PF4W5A3V_telem.xlsx
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-55-13/soc-PF4W5A3V_telem.json
/home/myuser/dev/perfspect/perfspect_2024-09-03_17-55-13/soc-PF4W5A3V_telem.txt
默認情況下,Perfspect針對本地主機,即Perfspect正在運行的主機。當可以通過本地主機通過SSH到達遠程系統時,遠程系統也可以針對目標。
重要的是:確保遠程用戶具有無密碼的sudo訪問(或根特權),以充分利用Perfspect的功能。
使用預配置的私鑰來定位單個遠程系統:
$ ./perfspect report --target 192.168.1.42 --user fred --key ~/.ssh/fredkey
...
使用密碼來定位單個遠程系統:
$ ./perfspect report --target 192.168.1.42 --user fred
[email protected]'s password: ******
...
要定位多個遠程系統,使用YAML文件來提供必要的連接參數,例如:
$ cat targets.yaml
# This YAML file contains a list of remote targets with their corresponding properties.
# Each target has the following properties:
# name: The name of the target (optional)
# host: The IP address or host name of the target (required)
# port: The port number used to connect to the target via SSH (optional)
# user: The user name used to connect to the target via SSH (optional)
# key: The path to the private key file used to connect to the target via SSH (optional)
# pwd: The password used to connect to the target via SSH (optional)
#
# Note: If key and pwd are both provided, the key will be used for authentication.
#
# Security Notes:
# It is recommended to use a private key for authentication instead of a password.
# Keep this file in a secure location and do not expose it to unauthorized users.
#
# Below are examples. Modify them to match your environment.
targets:
- name: ELAINES_TARGET
host: 192.168.1.1
port:
user: elaine
key: /home/elaine/.ssh/id_rsa
pwd:
- name: JERRYS_TARGET
host: 192.168.1.2
port: 2222
user: jerry
key:
pwd: george
$ ./perfspect report --benchmark speed,memory --targets targets.yaml
...
builder/build.sh在提供所需的構建環境的Docker容器中構建依賴關係和應用程序。假設您在開發系統上安裝了Docker。
make構建應用程序。假設依賴關係以前已經構建,並且您已經在開發系統上安裝了。