-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_test_1.sh
executable file
·236 lines (206 loc) · 4.54 KB
/
run_test_1.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
PERIOD=1
IDX=0
DEV_BW=400
DEV_IOPS=50000
DEV_SIZE=440
DEV="8:16"
SPRBYTES=0
SPWBYTES=0
SPRIOP=0
SPWIOP=0
BPRBYTES=0
BPWBYTES=0
BPRIOP=0
BPWIOP=0
while getopts ":s:b:" opt; do
case $opt in
s)
S_USERS=$OPTARG
;;
b)
B_USERS=$OPTARG
;;
:)
"Option -$OPTARG requires an argument." >&2
exit 1
;;
\?)
echo "Invalid options: -$OPTARG." >&2
exit 1
;;
esac
done
OUTPUT_DIR=S$S_USERS-B$B_USERS
USERS=$(($S_USERS + $B_USERS))
BW=$(echo "scale=0; $DEV_BW/$S_USERS" | bc -l)
IOPS=$(echo "scale=0; $DEV_IOPS/$S_USERS" | bc -l)
VOL=$(echo "scale=0; $DEV_SIZE / $USERS" | bc -l)
TOTAL_S_BW_REQ=0
TOTAL_S_IOPS_REQ=0
ID=0
for i in `seq 1 $S_USERS`
do
while true
do
if [ -e .meta/S$ID.pid ]
then
ID=$(($ID + 1))
else
break
fi
done
#./create_user.sh -i S$i -L 10g -o $OUTPUT_DIR -s 0 -r 100 -a 16 -C S -b 4 -B $BW -I $IOPS &
./create_user.sh -i S$ID -L 10g -o $OUTPUT_DIR -s 0 -r 100 -t 8 -T 4 -C S -b 8 -B $BW -I $IOPS &
TOTAL_S_BW_REQ=$(($TOTAL_S_BW_REQ+$BW))
TOTAL_S_IOPS_REQ=$(($TOTAL_S_IOPS_REQ+$IOPS))
ID=$(($ID + 1))
done
B_BW_LIMIT=0
B_IOPS_LIMIT=0
ID=0
for i in `seq 1 $B_USERS`
do
while true
do
if [ -e .meta/B$ID.pid ]
then
ID=$(($ID + 1))
else
break
fi
done
#./create_user.sh -i B$i -L 10g -o $OUTPUT_DIR -s 0 -r 100 -a 16 -C B -b 4 -B $BW -I $IOPS &
./create_user.sh -i B$i -L 10g -o $OUTPUT_DIR -s 0 -r 100 -t 1 -C B -b 8 -B $BW -I $IOPS &
#B_BW_LIMIT=$(($B_BW_LIMIT+$BW))
#B_IOPS_LIMIT=$(($B_IOPS_LIMIT+$IOPS))
B_BW_LIMIT=10
B_IOPS_LIMIT=2560
ID=$(($ID + 1))
done
PREV_B_IOPS_LIMIT=-1
PREV_B_BW_LIMIT=-1
if [ -e .meta/monitor ]
then
exit 0
fi
touch .meta/monitor
CURR_S_BW_REQ=$TOTAL_S_BW_REQ
CURR_S_IOPS_REQ=$TOTAL_S_IOPS_REQ
LT_CNT=0
HT_CNT=0
CNT_TH=3
sleep 1
STATE=0
while true
do
SRBYTES=0
SWBYTES=0
SRIOP=0
SWIOP=0
ID=0
for i in `seq 1 $S_USERS`
do
STAT=$(grep $DEV /root/cgroupv2/blkio_test_S$ID/io.stat)
ID=$(($ID + 1))
if [ -z "$STAT" ]
then
continue
fi
IFS='\ =' read -ra VAL <<< "$STAT"
#8:16 rbytes 205180092416 wbytes 0 rios 25046398 wios 0
SRBYTES=$(($SRBYTES + ${VAL[2]}))
SWBYTES=$(($SWBYTES + ${VAL[4]}))
SRIOP=$(($SRIOP + ${VAL[6]}))
SWIOP=$(($SWIOP + ${VAL[8]}))
done
STAT=$(grep $DEV /root/cgroupv2/BE/io.stat)
if [ -z "$STAT" ]
then
continue
fi
IFS='\ =' read -ra VAL <<< "$STAT"
BRBYTES=${VAL[2]}
BWBYTES=${VAL[4]}
BRIOP=${VAL[6]}
BWIOP=${VAL[8]}
SRBW=$(echo "scale=0; ($SRBYTES-$SPRBYTES)/1000000/$PERIOD" | bc -l)
#SRIOPS=$(echo "($SRIOP-$SPRIOP)/1000" | bc -l)
SRIOPS=$(echo "scale=0; ($SRIOP-$SPRIOP)/$PERIOD" | bc -l)
SPRBYTES=$SRBYTES
SPRIOP=$SRIOP
BRBW=$(echo "scale=0; ($BRBYTES-$BPRBYTES)/1000000/$PERIOD" | bc -l)
#BRIOPS=$(echo "($BRIOP-$BPRIOP)/1000" | bc -l)
BRIOPS=$(echo "scale=0; ($BRIOP-$BPRIOP)/$PERIOD" | bc -l)
BPRBYTES=$BRBYTES
BPRIOP=$BRIOP
echo "Shared users: read $SRBW MB/s $SRIOPS IOPS BW limit: $CURR_S_BW_REQ IOPS limit: $CURR_S_IOPS_REQ"
echo "BE users: read $BRBW MB/s $BRIOPS IOPS"
TOTAL_RBW=$(($SRBW+$BRBW))
TOTAL_RIOPS=$(($SRIOPS+$BRIOPS))
case $STATE in
0)
B_BW_LIMIT=$(($B_BW_LIMIT - 10))
if [ $B_BW_LIMIT -lt 10 ]
then
B_BW_LIMIT=10
STATE=2
else
PREV_SRBW=$SRBW
STATE=1
fi
B_IOPS_LIMIT=$(($B_BW_LIMIT * 256))
;;
1)
if [ $SRBW -gt $(echo "scale=0; ($PREV_SRBW * 1.05)/1" | bc -l) ]
then
STATE=2
PREV_SRBW=$SRBW
else
B_BW_LIMIT=$((B_BW_LIMIT + 10))
B_IOPS_LIMIT=$(($B_BW_LIMIT * 256))
STATE=2
fi
;;
2)
B_BW_LIMIT=$((B_BW_LIMIT + 3))
B_IOPS_LIMIT=$(($B_BW_LIMIT * 256))
PREV_SRBW=$SRBW
STATE=3
;;
3)
if [ $SRBW -lt $(echo "scale=0; ($PREV_SRBW * 0.95)/1" | bc -l) ]
then
B_BW_LIMIT=$(($B_BW_LIMIT - 3))
B_IOPS_LIMIT=$(($B_BW_LIMIT * 256))
STATE=0
else
STATE=0
PREV_SRBW=$SRBW
fi
;;
esac
if [ $PREV_B_IOPS_LIMIT != $B_IOPS_LIMIT ]
then
#echo "$DEV bps=$(($B_BW_LIMIT * 1024 * 1024)) iops=$B_IOPS_LIMIT" > /root/cgroupv2/BE/io.max
set -x
echo "$DEV rbps=$(($B_BW_LIMIT * 1024 * 1024)) riops=$B_IOPS_LIMIT" > /root/cgroupv2/BE/io.max
set +x
PREV_B_BW_LIMIT=$B_BW_LIMIT
PREV_B_IOPS_LIMIT=$B_IOPS_LIMIT
else
if [ $PREV_B_BW_LIMIT != $B_BW_LIMIT ]
then
#echo "$DEV bps=$(($B_BW_LIMIT * 1024 * 1024)) iops=$B_IOPS_LIMIT" > /root/cgroupv2/BE/io.max
set -x
echo "$DEV rbps=$(($B_BW_LIMIT * 1024 * 1024)) riops=$B_IOPS_LIMIT" > /root/cgroupv2/BE/io.max
PREV_B_BW_LIMIT=$B_BW_LIMIT
PREV_B_IOPS_LIMIT=$B_IOPS_LIMIT
set +x
fi
fi
S_CNT=$(ls .meta/S*.pid | wc -l)
TOTAL_S_BW_REQ=$(($BW * $S_CNT))
TOTAL_S_IOPS_REQ=$(($IOPS * $S_CNT))
sleep $PERIOD
done