-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplot-writeback_single_inode.sh
executable file
·88 lines (67 loc) · 2.07 KB
/
plot-writeback_single_inode.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
for dir
do
# writeback_single_inode: bdi 0:21: ino=7307423 state=I_DIRTY_DATASYNC dirtied_when=xxx age=0 wrote=460 nr_to_write=14862
# 2 3 4 5 6
plot_inode() {
data=$1
suffix=$2
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 output "writeback_single_inode$suffix.png"
set ylabel "size (MB)"
set y2label "time (s)"
set ytics nomirror
set y2tics
plot "$data" using 1:(\$7/256) axis x1y1 with points pt 5 ps 0.6 title "wrote", \
"$data" using 1:4 axis x1y2 with points pt 1 ps 0.6 title "age"
EOF
}
plot() {
data=$1
suffix=$2
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 output "writeback_single_inode$suffix.png"
set ylabel "size (MB)"
plot "$data" using 1:(\$6/256) with linespoints pt 4 ps 0.6 lc rgbcolor "green" title "nr_to_write", \
"$data" using 1:(\$7/256) with points pt 5 ps 0.6 lc rgbcolor "red" title "wrote"
EOF
}
cd $dir
[[ -f trace || -f trace.bz2 ]] || exit
trace=trace-writeback_single_inode
# ino=$(cat trace | awk '/writeback_single_inode.*I_DIRTY/{if ($6 == "0:15:") continue; print $7; exit}')
ino=$(awk '{print $1; exit}' ls-files)
[[ -n $ino ]] || exit
trace_tab() {
grep -o "[0-9.]\+: $1: .*" |\
sed -e 's/bdi [^ ]\+//' \
-e 's/[^0-9.-]\+/ /g'
}
bzcat trace.bz2 | grep -F "writeback_single_inode" |\
trace_tab writeback_single_inode |\
awk '{ if ($6 < 123456789) print }' > $trace
plot $trace
awk "{ if (\$2 == $ino) print }" < $trace > $trace-ino=$ino
plot_inode $trace-ino=$ino -ino=$ino
# lines=$(wc -l $trace | cut -f1 -d' ')
# if [[ $lines -ge 300 ]]; then
# old_width=$width
# width=8000
# plot $trace +
# width=$old_width
# fi
# tail -n 300 < $trace > $trace-300
# plot $trace-300 -300
rm $trace*
cd -
done