forked from brendangregg/FlameGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackcollapse-lockstat.awk
More file actions
executable file
·44 lines (43 loc) · 1.96 KB
/
stackcollapse-lockstat.awk
File metadata and controls
executable file
·44 lines (43 loc) · 1.96 KB
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
#!/usr/bin/awk -f
#
# This program generates collapsed stacks fit for use by flamegraph.pl
# from Solaris /usr/bin/lockstat -kIW -s <stkdepth> output, e.g.:
#
# Usage:
#
# /usr/bin/lockstat -kIW -i 977 -s 32 sleep 10 > lockstat.out
# ./stackcollapse-lockstat.awk lockstat.out > stacks.folded
# ./flamegraph.pl stacks.folded > stacks.svg
#
# Example of lockstat.out:
# ------------------------------------------------------------------------------
# Count indv cuml rcnt nsec Hottest CPU+PIL Caller
# 4 0% 100% 0.00 1202 cpu[27] disp_getwork_cpu
#
# nsec ------ Time Distribution ------ count Stack
# 1024 |@@@@@@@ 1
# 2048 |@@@@@@@@@@@@@@@@@@@@@@ 3
# ------------------------------------------------------------------------------
# Count indv cuml rcnt nsec Hottest CPU+PIL Caller
# 4 0% 100% 0.00 1828 cpu[0]+10 mutex_enter
#
# nsec ------ Time Distribution ------ count Stack
# 2048 |@@@@@@@@@@@@@@@@@@@@@@ 3 run_interrupt_thread
# 4096 |@@@@@@@ 1 clock_tick_process
# clock_tick_execute_common
# clock_tick_schedule
# clock
# cyclic_softint
# cbe_level10
# dispatch_handler
# run_interrupt_thread
# ------------------------------------------------------------------------------
/^---/ {x = 0; if (stk) stacks[stk] += cnt}
x == 3 && NF != 3 { stk = $NF ";" stk }
x == 2 && $NF == "Stack" {x=3}
x == 1 {cnt=$1; stk=$NF; x=2}
$1 == "Count" {x=1}
END {
if (stk) stacks[stk] += cnt;
for (stk in stacks) print stk " " stacks[stk];
}