常用系统性能工具
查看CPU核数
cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l
笔记本关闭盖子不休眠
/etc/systemd/logind.conf
HandleLidSwitch=ignore
systemctl restart systemd-logind
[root@localhost ~]# mpstat
Linux 3.10.0-1127.rt56.1093.el7.x86_64 (localhost) 03/25/2021 _x86_64_ (24 CPU)
01:26:53 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
01:26:53 AM all 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 99.99
[root@localhost ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1623272 2096 202408 0 0 0 0 3 3 0 0 100 0 0
[root@localhost ~]# iostat
Linux 3.10.0-1127.rt56.1093.el7.x86_64 (localhost) 03/25/2021 _x86_64_ (24 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.00 0.00 0.01 0.00 0.00 99.99
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 0.08 0.27 0.53 134298 263172
sdb 0.00 0.00 0.00 2112 0
[root@localhost ~]# strace -p 1662
strace: Process 1662 attached
alarm(333) = 94
ioctl(3, FIONREAD, [100]) = 0
[root@xuperior-pc gcc-10.2.0]# strace -h
Usage: strace [-ACdffhikqqrtttTvVwxxyyzZ] [-I N] [-b execve] [-e EXPR]...
[-a COLUMN] [-o FILE] [-s STRSIZE] [-X FORMAT] [-O OVERHEAD]
[-S SORTBY] [-P PATH]... [-p PID]... [-U COLUMNS] [--seccomp-bpf]
{ -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }
or: strace -c[dfwzZ] [-I N] [-b execve] [-e EXPR]... [-O OVERHEAD]
[-S SORTBY] [-P PATH]... [-p PID]... [-U COLUMNS] [--seccomp-bpf]
{ -p PID | [-DDD] [-E VAR=VAL]... [-u USERNAME] PROG [ARGS] }
[root@localhost ~]# perf
usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
c2c Shared Data C2C/HITM Analyzer.
config Get and set variables in a configuration file.
data Data file related processing
diff Read perf.data files and display the differential profile
evlist List the event names in a perf.data file
ftrace simple wrapper for kernel's ftrace functionality
inject Filter to augment the events stream with additional information
kallsyms Searches running kernel for symbols
kmem Tool to trace/measure kernel memory properties
kvm Tool to trace/measure kvm guest os
list List all symbolic event types
lock Analyze lock events
mem Profile memory accesses
record Run a command and record its profile into perf.data
report Read perf.data (created by perf record) and display the profile
sched Tool to trace/measure scheduler properties (latencies)
script Read perf.data (created by perf record) and display trace output
stat Run a command and gather performance counter statistics
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
version display the version of perf binary
probe Define new dynamic tracepoints
trace strace inspired tool
See 'perf help COMMAND' for more information on a specific command.