分析和优化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构建应用程序。假设依赖关系以前已经构建,并且您已经在开发系统上安装了。