首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >linux性能命令总结

linux性能命令总结

作者头像
mingjie
发布2022-05-12 10:50:57
发布2022-05-12 10:50:57
1.2K0
举报

notes

代码语言:javascript
复制
perf stat -a sleep 10
perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles -a sleep 10
perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores -a sleep 10
perf stat -e dTLB-loads,dTLB-load-misses,dTLB-prefetch-misses -a sleep 10
perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches -a sleep 10
perf stat -e 'syscalls:sys_enter_*' -a sleep 10
perf stat -e 'vmscan:*' -a sleep 10

# 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

# Various CPU level 1 data cache statistics for the specified command:
perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores command

# Various CPU data TLB statistics for the specified command:
perf stat -e dTLB-loads,dTLB-load-misses,dTLB-prefetch-misses command

# Various CPU last level cache statistics for the specified command:
perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches command

# Using raw PMC counters, eg, counting unhalted core cycles:
perf stat -e r003c -a sleep 5 

# PMCs: counting cycles and frontend stalls via raw specification:
perf stat -e cycles -e cpu/event=0x0e,umask=0x01,inv,cmask=0x01/ -a sleep 5

# Count syscalls per-second system-wide:
perf stat -e raw_syscalls:sys_enter -I 1000 -a

# Count system calls by type for the specified PID, until Ctrl-C:
perf stat -e 'syscalls:sys_enter_*' -p PID

# Count system calls by type for the entire system, for 5 seconds:
perf stat -e 'syscalls:sys_enter_*' -a sleep 5

# Count scheduler events for the specified PID, until Ctrl-C:
perf stat -e 'sched:*' -p PID

# Count scheduler events for the specified PID, for 10 seconds:
perf stat -e 'sched:*' -p PID sleep 10

# Count ext4 events for the entire system, for 10 seconds:
perf stat -e 'ext4:*' -a sleep 10

# Count block device I/O events for the entire system, for 10 seconds:
perf stat -e 'block:*' -a sleep 10

# Count all vmscan events, printing a report every second:
perf stat -e 'vmscan:*' -a -I 1000
代码语言:javascript
复制
# ftrace 记录上下文切换事件,结合kernelshark实用最佳
trace-cmd record -F -b 100000 -e 'sched_wakeup*' -e sched_switch -e 'sched_migrate*' ./cmd


# ftrace 记录函数调用,单位us
trace-cmd record -F -M 5 -c -p function_graph ./cmd



# perf kvm事件
perf kvm stat -e kvm0:kvm_exit -e kvm0:kvm_entry -e kvm0:kvm_cpuid -e kvm0:kvm_msr -e kvm0:kvm_apic_ipi -e kvm0:kvm_apic_accept_irq -e kvm0:kvm_ple_window -e kvm0:kvm_fpu -a sleep 10


# perf 火焰图流程,注意频率对结果的影响
perf record -F 999 -a -g ./cmd
perf script > out.perf
/root/FlameGraph-master/stackcollapse-perf.pl out.perf > out.folded
/root/FlameGraph-master/flamegraph.pl out.folded > result.svg


# 抓包,1G缓冲不丢包,按主机IP,不切割结果
tcpdump -ttt -n -i eth0 -s 0 -B 1048576 ip host xxx and yyy -w s.pcap


# 抓包,2G缓冲不丢包,按端口,自动切割结果
tcpdump -ttt -n -i eth0 -s 0 -B 2097151 tcp port xxx -G 10 -W 1 -w s.pcap
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-04-13,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档