blob: e7f0da6282e06f86682f07a4848c2919bfaea25c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
.:: debugging ::.
--------------------------------------------------------------------------------
# print syscalls of process with all threads (-f) of running process
strace -f -p <pid>
# only trace certain syscalls
strace -f -p <pid> -e trace=open,socket
# trace signals delivered to process
strace -f -p <pid> -e signal
# dump stack of process and all threads
pstack <pid>
# print file flags
# +fg print file flag abbreviations
lsof +fg -p <pid>
# print process virt mem map
# compared to /proc/<>/maps it shows the size of the mappings
pmap <pid>
# trace minor/major page faults
pidstat -r -p <pid> [interval]
# statistics of process run
/usr/bin/time -v <cmd>
# get supported events
perf list
## show process stats
perf stat -p <pid>
perf stat -p <pid> -I <ms>
# select events of interests
perf stat -p <pid> -e cycles,faults,cache-misses,context-switches
# -K hide kernel threads
perf top -F 99 -p <pid> -K
## record measurement into db
# -g uses 'fb' = frame-pointer as default method to collect backtraces
# tell gcc to not optimize fp out -fno-omit-frame-pointer
perf record -F 99 -p <pid> -g
# use post processing and dwarf to collect backtraces
perf record -F 99 -p <pid> --call-graph dwarf
perf record -F 99 -p <pid> -e instructions,cpu-cycles,faults,cache-misses,context-switches
## report perf db
# print to stdio
perf report -n --stdio
# use tui
perf report -g graph,0.5,caller
# flamegraph (https://github.com/brendangregg/FlameGraph)
# record events of interest, eg page-faults
perf record -e page-faults --call-graph dwarf
perf script | FlameGraph/stackcollapse-perf.pl > out.perf-folded
FlameGraph/flamegraph.pl out.perf-folded > perf-trace.svg
# record multiple events and generate flamegraphs
perf record --call-graph dwarf -p $(pgrep -u jstolp -n sim) -F 200 -e cpu-cycles,page-faults
perf script --per-event-dump
# fold & generate as above
# print supported events
ophelp
operf -p <pid>
opreport -c
opreport -l
--------------------------------------------------------------------------------
vim:sts=2:et:tw=80:cc=80:fo+=t:ft=help
|