forked from googleapis/storage-shared-benchmarking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·314 lines (301 loc) · 12.5 KB
/
run.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
#!/bin/bash
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# e: will cause the script to fail if any program it calls fails
# u: will cause the script to fail if any variable is used but it is not defined
# o pipefail will cause the script to fail if the pipe fails
set -euo pipefail
function print_usage() {
cat <<_EOM_
Usage: run.sh [options]
Options:
-h|--help Print this help message
--workload_1=<lang> Run workload 1 for <lang>
--workload_2=<lang> Run workload 2 for <lang>
--workload_6=<lang> Run workload 6 for <lang>
--workload_4=<lang> Run workload 4 for <lang>
--workload_8=<lang> Run workload 8 for <lang>
--project=<project> Use <project> as project to use for workloads
--bucket=<bucket> Use <bucket> as bucket to use for workloads
--api=<api> Use <api> when executing workloads
--samples=<samples> Number of samples to report
--workers=<workers> Number of workers to use when running workload
--object_size=<object_size> Object size to use when running workload
--directory_num_objects Number of objects in a directory (for workload 6)
--region=<region> Region used by workload7
--upload_function=<fn> Upload function name used by workload7
--crc32c=<enabled> Crc32c is enabled, disabled, random used by workload7
--md5=<enabled> Md5 is enabled, disabled, random used by workload7
--minimum_read_offset=<int> Minimum read offset for range reads
--maximum_read_offset=<int> Maximum read offset for range reads
--write_buffer_size=<int> Used when write buffer should contain the entire object (large object multipart uploads)
--read_offset_quantum=<int> Quantum read offset for range reads
--range_read_size=<int> Range size to read from object for range reads
--timeout=<duration> Duration of time after which script should stop benchmarking and perform cleanup
--warmup=<int> Number of seconds that the cli should run to warmup before a workload
_EOM_
}
PARSED="$(getopt -a \
--options="h" \
--longoptions="help,workload_1:,workload_2:,workload_4:,workload_6:,workload_8:,workload_write_only:,bidi_enabled:,project:,bucket:,api:,samples:,object_size:,directory_num_objects:,samples:,workers:,region:,upload_function:,crc32c:,md5:,minimum_read_offset:,maximum_read_offset:,read_offset_quantum:,write_buffer_size:,range_read_size:,timeout:,warmup:" \
--name="run.sh" \
-- "$@")"
eval set -- "${PARSED}"
# Get absolute path to this script to call relative files
ROOT_PATH=$(dirname $(readlink -f "${BASH_SOURCE:-$0}"))
NVM_HOME="/root/.nvm"
WORKLOAD=
BIDI_ENABLED=
PROJECT=
BUCKET_NAME=
API=
OBJECT_SIZE=
DIR_NUM_OBJECTS=
SAMPLES=
WORKERS=
REGION=
UPLOAD_FUNCTION=
CRC32C="disabled"
MD5="disabled"
WRITE_BUFFER_SIZE=
MINIMUM_READ_OFFSET=
MAXIMUM_READ_OFFSET=
READ_OFFSET_QUANTUM=
RANGE_READ_SIZE=
TIMEOUT=
WARMUP=
FORWARD_ARGS=
while true; do
case "$1" in
-h | --help)
print_usage
exit 0
;;
--workload_1)
WORKLOAD="workload_1_$2"
shift 2
;;
--workload_2)
WORKLOAD="workload_2_$2"
shift 2
;;
--workload_4)
WORKLOAD="workload_4_$2"
shift 2
;;
--workload_6)
WORKLOAD="workload_6_$2"
shift 2
;;
--workload_8)
WORKLOAD="workload_8_$2"
shift 2
;;
--workload_write_only)
WORKLOAD="workload_write_only_$2"
shift 2
;;
--bidi_enabled)
BIDI_ENABLED="$2"
shift 2
;;
--project)
PROJECT="$2"
shift 2
;;
--bucket)
BUCKET_NAME="$2"
shift 2
;;
--api)
API="$2"
shift 2
;;
--object_size)
OBJECT_SIZE="$2"
shift 2
;;
--samples)
SAMPLES="$2"
shift 2
;;
--workers)
WORKERS="$2"
shift 2
;;
--region)
REGION="$2"
shift 2
;;
--upload_function)
UPLOAD_FUNCTION="$2"
shift 2
;;
--crc32c)
CRC32C="$2"
shift 2
;;
--md5)
MD5="$2"
shift 2
;;
--minimum_read_offset)
MINIMUM_READ_OFFSET="$2"
shift 2
;;
--maximum_read_offset)
MAXIMUM_READ_OFFSET="$2"
shift 2
;;
--read_offset_quantum)
READ_OFFSET_QUANTUM="$2"
shift 2
;;
--write_buffer_size)
WRITE_BUFFER_SIZE="$2"
shift 2
;;
--range_read_size)
RANGE_READ_SIZE="$2"
shift 2
;;
--timeout)
TIMEOUT="$2"
shift 2
;;
--warmup)
WARMUP="$2"
shift 2
;;
--directory_num_objects)
DIR_NUM_OBJECTS="$2"
shift 2
;;
--)
# condition attempts to access $2 otherwise skip
if [ ! -z "${2-}" ]; then
FORWARD_ARGS="$2"
fi
shift
break
;;
esac
done
workload_1_golang() {
golang_benchmark_cli -project "${PROJECT}" \
-bucket "${BUCKET_NAME}" \
-workers "${WORKERS}" \
-samples "${SAMPLES}" \
-object_size "${OBJECT_SIZE}" \
-api "${API}" \
-timeout "${TIMEOUT}"
}
workload_2_golang() {
golang_benchmark_cli -project "${PROJECT}" \
-bucket "${BUCKET_NAME}" \
-workers "${WORKERS}" \
-samples "${SAMPLES}" \
-object_size "${OBJECT_SIZE}" \
-api "${API}" \
-timeout "${TIMEOUT}" \
-range_read_size "${RANGE_READ_SIZE}"
}
workload_6_golang() {
golang_benchmark_cli -project "${PROJECT}" \
-bucket "${BUCKET_NAME}" \
-workers "${WORKERS}" \
-samples "${SAMPLES}" \
-object_size "${OBJECT_SIZE}" \
-api "${API}" \
-timeout "${TIMEOUT}" \
-workload 6 \
-directory_num_objects "${DIR_NUM_OBJECTS}"
}
workload_1_nodejs() {
. $NVM_HOME/nvm.sh
node /usr/bin/nodejs_benchmark_cli/build/cjs/internal-tooling/performanceTest.js --project "${PROJECT}" \
--bucket "${BUCKET_NAME}" \
--test_type "w1r3" \
--object_size "${OBJECT_SIZE}..${OBJECT_SIZE}" \
--workers "${WORKERS}" \
--output_type "cloud-monitoring" \
--samples "${SAMPLES}"
}
workload_2_nodejs() {
. $NVM_HOME/nvm.sh
node /usr/bin/nodejs_benchmark_cli/build/cjs/internal-tooling/performanceTest.js --project "${PROJECT}" \
--bucket "${BUCKET_NAME}" \
--test_type "range-read" \
--object_size "${OBJECT_SIZE}..${OBJECT_SIZE}" \
--range_read_size "${RANGE_READ_SIZE}" \
--workers "${WORKERS}" \
--output_type "cloud-monitoring" \
--samples "${SAMPLES}"
}
workload_1_python() {
python3 /usr/bin/python_benchmark_cli/tests/perf/benchmarking.py --project "${PROJECT}" \
--bucket "${BUCKET_NAME}" \
--bucket_region "${REGION}" \
--test_type "w1r3" \
--object_size "${OBJECT_SIZE}..${OBJECT_SIZE}" \
--workers "${WORKERS}" \
--output_type "cloud-monitoring" \
--samples "${SAMPLES}"
}
workload_2_python() {
python3 /usr/bin/python_benchmark_cli/tests/perf/benchmarking.py --project "${PROJECT}" \
--bucket "${BUCKET_NAME}" \
--bucket_region "${REGION}" \
--test_type "range" \
--object_size "${OBJECT_SIZE}..${OBJECT_SIZE}" \
--range_read_size "${RANGE_READ_SIZE}" \
--workers "${WORKERS}" \
--output_type "cloud-monitoring" \
--samples "${SAMPLES}"
}
workload_8_nodejs() {
. $NVM_HOME/nvm.sh
node /usr/bin/nodejs_benchmark_cli/build/internal-tooling/performanceTest.js --project "${PROJECT}" \
--bucket "${BUCKET_NAME}" \
--test_type "tm-chunked" \
--object_size "${OBJECT_SIZE}..${OBJECT_SIZE}" \
--range_read_size "${RANGE_READ_SIZE}" \
--workers "${WORKERS}" \
--output_type "cloud-monitoring" \
--samples "${SAMPLES}"
}
workload_1_java() {
java -Dio.grpc.netty.shaded.io.netty.native.workdir=/ -Dorg.conscrypt.native.workdir=/ -jar /usr/bin/java-cli -project="${PROJECT}" \
-bucket="${BUCKET_NAME}" \
-test_type="w1r3" \
-api="${API}" \
-object_size="${OBJECT_SIZE}..${OBJECT_SIZE}" \
-workers="${WORKERS}" \
-samples="${SAMPLES}" \
-warmup="${WARMUP}"
}
workload_write_only_java() {
java -Dio.grpc.netty.shaded.io.netty.native.workdir=/ -Dorg.conscrypt.native.workdir=/ -jar /usr/bin/java-cli -project="${PROJECT}" \
-bucket="${BUCKET_NAME}" \
-test_type="write-only" \
-api="${API}" \
-object_size="${OBJECT_SIZE}..${OBJECT_SIZE}" \
-workers="${WORKERS}" \
-samples="${SAMPLES}" \
-bidi_enabled="${BIDI_ENABLED}"
}
# Perform workload
# TODO: This can fail without non-zero result causing silent failures
COMMAND="${WORKLOAD}"
eval $COMMAND