-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplot-task-bw.sh
executable file
·70 lines (53 loc) · 1.56 KB
/
plot-task-bw.sh
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
#!/bin/bash
plot_lines() {
colors=(red gold web-blue cyan magenta slategray)
echo -n plot
for i in `seq 0 5`
do
[[ -f task-bw-${dd[$i]}$suffix ]] || break
[[ $i != 0 ]] && echo -n ,
echo -n \"task-bw-${dd[$i]}$suffix\" using '1:($3/1048576)' with steps lw 2.0 lc rgbcolor \"${colors[$i]}\" title \"task ${dd[$i]}\"
done
}
plot() {
suffix=$1
gnuplot <<EOF
set xlabel "time (s)"
set size 1
set terminal pngcairo size ${width:-1280}, 800
set terminal pngcairo size ${width:-1000}, 600
set terminal pngcairo size ${width:-1280}, ${height:-800}
set grid
set output "balance_dirty_pages-task-bw$suffix.png"
set ylabel "dirtied (MB)"
$(plot_lines)
EOF
}
for dir
do
cd $dir
[ -s pid ] || {
bzcat trace.bz2 | grep -F task_io | awk '/(dd|cp|tar|fio)-[0-9]+/{print $1}'| sed 's/[^0-9]//g' | head -n3000 | sort | uniq > dd-pid
}
declare -a dd
dd=($(cat pid dd-pid 2>/dev/null))
[[ ${#dd[*]} -lt 1 ]] && { cd ..; continue; }
# dd-3876 [014] 151.167682: balance_dirty_pages: bdi btrfs-1: limit=0 goal=247413 dirty=212307 bdi_goal=649 bdi_dirty=212395 base_bw=102400 task_bw=13300 dirtied=256 dirtied_pause=256 period think pause=77 paused=0
trace_tab() {
grep -o "[0-9.]\+: $1: .*" |\
sed -e 's/bdi [^ ]\+//' \
-e 's/[^0-9.-]\+/ /g'
}
for pid in ${dd[0]} ${dd[1]} ${dd[2]} ${dd[3]} ${dd[4]} ${dd[5]}
do
# if ($paused == 0) dirtied += $dirtied
bzcat trace.bz2 | grep -F -- "-$pid " | trace_tab task_io > task-bw-$pid
# tail -n300 task-bw-$pid > task-bw-$pid-300
done
if [[ -s task-bw-${dd[0]} ]]; then
plot
# plot -300
fi
rm task-bw-*
cd ..
done