-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_benchmark.sh
executable file
·339 lines (316 loc) · 8.64 KB
/
run_benchmark.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#!/bin/bash
set -o errexit -o pipefail -o noclobber -o nounset
cmd=$0
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echo 'erro: getopt failed'
exit 1
fi
path=`pwd`
h=0
# internal benchmarks are stored in here
## DEFAULTS:
i_dir="/var/scratch/$USER/"
o_dir="/var/scratch/${USER}/bm/"
count_conf=3000000
distr_conf=95
comps=(sd_sd wr_sd wr_wr wr_rd wrimm_sd)
sizes=(32 64 128 256 512 1024 2048)
offset=9
# Other stuff that can be managed through command line args
count=1000000
benchmarks=""
bm_cpu=0
bm_ops=0
bm_scale=0
bm_latency=0
scale=""
procs=""
reruns=1
all=0
OPTIONS="alocs:r:i:f:g:n:h"
LONGOPTS="all,latency,ops-per-sec,cpu-usage,scalability:,rerun:,input-conf:,output-folder:,num-requests:,input-folder,help"
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
exit 2
fi
eval set -- "$PARSED"
while true && [ $# -gt 1 ]; do
case "$1" in
-a|--all)
bm_cpu=1
bm_scale=1
bm_latency=1
scale=(1 2 4 8 16)
procs=(1 2)
all=1
shift ;;
-l|--latency)
if [[ $all == 1 ]]; then
echo "already doing all benchmarks, -l ignored"
else
bm_latency=1
fi
shift ;;
-o|--ops-per-sec)
if [[ $all == 1 ]]; then
echo "already doing all benchmarks, -o ignored"
else
bm_ops=1
fi
shift ;;
-c|--cpu-usage)
if [[ $all == 1 ]]; then
echo "already doing all benchmarks, -c ignored"
else
bm_cpu=1
fi
shift ;;
-s|--scalability)
if [[ $all == 1 ]]; then
echo "already doing all benchmarks, -s ignored"
else
bm_scale=1
IFS=',' read -ra scale <<< "$2"
fi
shift 2 ;;
-r|--rerun)
rerun=$2
shift 2 ;;
-i|--input-conf)
i_dir=$2
shift 2 ;;
-f|--output-folder)
o_dir=$2
shift 2 ;;
-n|--num-requests)
count=$2
shift 2 ;;
-h|--help)
h=1
break
shift ;;
--)
shift ;;
*)
echo "error parsing arguments"
exit 1 ;;
esac
done
if [ $h == 1 ]
then
echo "Usage: $cmd [OPTIONS]..
Options:
-a, --all measure everything, defaults <cores> to 1,2,4,8,16
-l, --latency measure latency client->server->client
-o, --ops-per-sec measure operations per second performed server side
-c, --cpu-usage measure cpu usage on server and client side
-s, --scalability=<cores> do specified benchmarks with <cores> clients
-i, --input-conf=<conf> use specified input file configuration, uses files as generated by
gen_small_workload.py, <conf> should look like:
<num-requests>_<get-distribution>_<payload-size>, e.g.
1000000_95_32, for 1000000 requests, of which 95% GETs, max size 32 bytes
-n, --num-requests=<N> the number of requests to actually do, 1,000,000 by default
-f, --output-folder=<out> use the specified output folder to
-h, --help display help
"
exit 0
fi
#echo "set options[bms:${benchmarks}; cpu:${bm_cpu}; scale:${bm_scale}=${scale[@]};] for user $USER"
R='\033[0;31m'
C='\033[0;36m'
NC='\033[0m'
info() { echo -e "${C}===[INFO]=== ${1}${NC}"; }
get_das5_node_ip() {
echo "10.149.0.${1}"
}
reserve_server_node() {
preserve -np 1 -t 28800 >/dev/null
rid=""
while [ "${rid}" == "" ]; do
rid=`preserve -llist | grep $USER | awk '{print $1}'`
sleep 1
done
echo "${rid}"
}
get_node_num() {
node=""
while [ "${node}" == "-" ] || [ "${node}" == "" ]; do
node=`preserve -llist | grep $USER | awk '{print $9}'`
sleep 2
done
echo "${node: -2}"
}
run_server() {
m=$1
ip=$2
rid=$3
port=20838
if [ "$m" == "0" ]; then
bm_type=$4
scale=$5
run=$6
prun -reserve $rid -np 1 -t 7200 -o ${o_dir}.s_${bm_type}.mcd.${in_conf}.${cores}.r$run memcached -v -d -u $USER -l $ip -p $port &
else
comp=$4
cores=$5
bm_type=$6
run=$7
prun -reserve $rid -np 1 -t 7200 -o ${o_dir}s_${bm_type}.${comp}.${in_conf}.${cores}.r$run ./bin/perk_server -r $comp -a $ip -p $port &
fi
}
run_server_perf() {
m=$1
ip=$2
rid=$3
port=20838
if [ "$m" == "0" ]; then
run=$4
prun -reserve $rid -np 1 -t 3600 -o ${o_dir}s_bm_cpu.mcd.${in_conf}.1_1.r$run perf stat memcached -u $USER -l $ip -p $port -t 16 &
else
comp=$4
cores=$5
bm_type=$6
run=$7
prun -reserve $rid -np 1 -t 3600 -o ${o_dir}s_bm_cpu.${comp}.${in_conf}.1_${cores}.r$run perf stat ./bin/perk_server -r $comp -a $ip -p $port &
fi
}
run_clients_perf() {
m=$1
ip=$2
port=20838
num_p=$3
num_n=$4
count=$5
if [ "$m" == "0" ]; then
run=$6
prun -$num_p -np $num_n -o ${o_dir}cl_bm_cpu.mcd.${in_conf}.${num_p}_${num_n}.r$run perf stat ./bin/client_mcd -a $ip -p $port -c $count -u -i $in_file
else
comp=$6
run=$7
prun -$num_p -np $num_n -o ${o_dir}cl_bm_cpu.${comp}.${in_conf}.${num_p}_${num_n}.r$run perf stat ./bin/perk_client -r $comp -a $ip -p $port -c $count -u -i $in_file
fi
}
kill_server() {
rid=$2
if [ "$1" == "0" ]; then
prun -reserve $rid -np 1 python3 util/kill_server.py memcached
elif [ "$1" == "2" ]; then
prun -reserve $rid -np 1 python3 util/kill_server.py memcachedp
else
prun -reserve $rid -np 1 pkill -f perk_server >/dev/null
fi
}
run_clients() {
m=$1
ip=$2
port=20838
num_p=$3
num_n=$4
count=$5
if [ "$m" == "0" ]; then
bm_type=$6
run=$7
prun -$num_p -np $num_n -t 1800 -o ${o_dir}cl_${bm_type}.mcd.${in_conf}.${num_p}_${num_n}.r$run ./bin/client_mcd -a $ip -p $port -c $count -u -i $in_file
else
comp=$6
bm_type=$7
run=$8
prun -$num_p -np $num_n -t 1800 -o ${o_dir}cl_${bm_type}.${comp}.${in_conf}.${num_p}_${num_n}.r$run ./bin/perk_client -r $comp -a $ip -p $port -c $count -u -i $in_file
fi
}
for csz in "${sizes[@]}"; do
vsz=`expr ${csz} - ${offset}`
in_file="${i_dir}input_${count}_${csz}_${distr_conf}_"
in_conf="${count_conf}_${csz}_${distr_conf}"
echo $in_file
for i in $(seq 1 $rerun); do
# reserve a node for the server
info "RESERVING NODE FOR SERVER, RUN $i SIZE $csz"
rid="$(reserve_server_node)"
node="$(get_node_num)"
sr_ip="$(get_das5_node_ip ${node})"
echo "acquired node, reservation id: ${rid}, node ${node}"
if [ "$bm_scale" == "1" ]; then
info "PREPARING BENCHMARKS"
PERK_OVERRIDE_VALSIZE=${vsz} PERK_BM_SERVER_EXIT=1 PERK_BM_OPS_PER_SEC=1 cmake .
make
info "BENCHMARKING PERK OPS/SEC"
for comp in "${comps[@]}"
do
for core in "${scale[@]}"
do
if [ "$core" == "32" ]; then
for proc in "${procs[@]}"
do
info "RUNNING PERK SERVER"
run_server 1 $sr_ip $rid $comp $core bm_scale $i
info "Running ops/sec benchmark with ${core}*${proc} clients"
run_clients 1 $sr_ip 2 16 $count $comp bm_scale $i
done
else
info "RUNNING PERK SERVER"
run_server 1 $sr_ip $rid $comp $core bm_scale $i
info "Running ops/sec benchmark with $core clients"
run_clients 1 $sr_ip $core 1 $count $comp bm_scale $i
fi
done
done
comp=mcd
info "BENCHMARKING MCD OPS/SEC"
for core in "${scale[@]}"
do
info "RUNNING MCD SERVER"
run_server 0 $sr_ip $rid bm_scale $scale $i
sleep 2
info "Running ops/sec benchmark with $core clients"
run_clients 0 $sr_ip $core 1 $count bm_scale $i
info "KILLING MCD SERVER"
kill_server 0 $rid
sleep 2
done
fi
if [ "$bm_cpu" == "1" ]; then
info "PREPARING CPU BENCHMARK"
PERK_OVERRIDE_VALSIZE=${vsz} PERK_BM_OPS_PER_SEC=1 PERK_BM_SERVER_EXIT=1 cmake .
make
info "BENCHMARKING CPU USAGE PERK"
for comp in "${comps[@]}"
do
info "RUNNING PERK SERVER"
run_server_perf 1 $sr_ip $rid $comp 1 bm_cpu $i
info "RUNNING PERK CLIENT"
run_clients_perf 1 $sr_ip 1 1 $count $comp $i
done
info "RUNNING MCD SERVER"
run_server_perf 0 $sr_ip $rid $i
info "RUNNING MCD CLIENT"
run_clients_perf 0 $sr_ip 1 1 $count $i
kill_server 2 $rid
fi
if [ "$bm_latency" == "1" ]; then
info "PREPARING LATENCY BENCHMARK"
echo PERK_OVERRIDE_VALSIZE=${vsz} PERK_BM_SERVER_EXIT=1 PERK_BM_LATENCY=1 cmake .
PERK_OVERRIDE_VALSIZE=${vsz} PERK_BM_SERVER_EXIT=1 PERK_BM_LATENCY=1 cmake .
make
info "BENCHMARKING PERK LATENCY"
for comp in "${comps[@]}"
do
info "RUNNING PERK SERVER"
run_server 1 $sr_ip $rid $comp 1 bm_lat $i
info "RUNNING PERK CLIENT"
run_clients 1 $sr_ip 1 1 $count $comp bm_lat $i
done
info "RUNNING MCD SERVER"
run_server 0 $sr_ip $rid bm_lat 1 $i
info "RUNNING MCD CLIENT"
run_clients 0 $sr_ip 1 1 $count bm_lat $i
kill_server 0 $rid
fi
info "Cancelling server node reservation"
preserve -c ${rid}
rid=""
node=""
sleep 2
done
done