Skip to content

Commit 7b77918

Browse files
committed
bash enhancements
added depth_to_xyz experiment
1 parent bfc8429 commit 7b77918

28 files changed

+711
-373
lines changed

tests/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
res
2+
res-*
23
perf.data
34
perf.data.old
45
samples

tests/bash_libraries/experiment_globals.sh

+10-125
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,20 @@
33
if [ -n "$__experiment_server_globals_sh__" ]; then return; fi
44
__experiment_server_globals_sh__=$(date)
55

6+
# App WASM so files:
7+
declare -r FIBONACCI="fibonacci.wasm.so"
8+
declare -r EKF="gps_ekf.wasm.so"
9+
declare -r CIFAR10="cifar10.wasm.so"
10+
declare -r GOCR="gocr.wasm.so"
11+
declare -r LPD="license_plate_detection.wasm.so"
12+
declare -r RESIZE="resize_image.wasm.so"
13+
declare -r CNN="cnn_face_detection.wasm.so"
14+
615
# The global configs for the scripts
716
declare -gr SERVER_LOG_FILE="perf.log"
817
declare -gr SERVER_HTTP_LOG_FILE="http_perf.log"
918
declare -gr HEY_OPTS="-disable-compression -disable-keepalive -disable-redirects"
1019

11-
# Globals to fill during run_init in run.sh, to use in base and generate_spec
12-
declare -A ports=()
13-
declare -A repl_periods=()
14-
declare -A max_budgets=()
15-
declare -A wasm_paths=()
16-
declare -A expected_execs=()
17-
declare -A deadlines=()
18-
declare -A resp_content_types=()
19-
declare -A arg_opts_hey=()
20-
declare -A arg_opts_lt=()
21-
declare -A args=()
22-
declare -A concurrencies=()
23-
declare -A rpss=()
24-
declare -a workloads=()
25-
declare -A workload_tids=()
26-
declare -A workload_deadlines=()
27-
declare -A workload_vars=()
28-
2920
# Sandbox Perf Log Globals:
3021
declare -ga SANDBOX_METRICS=(total queued uninitialized allocated initialized runnable interrupted preempted running_sys running_user asleep returned complete error)
3122
declare -gA SANDBOX_METRICS_FIELDS=(
@@ -48,6 +39,7 @@ declare -gr SANDBOX_TENANT_NAME_FIELD=2
4839
declare -gr SANDBOX_ROUTE_FIELD=3
4940
declare -gr SANDBOX_CPU_FREQ_FIELD=20
5041
declare -gr SANDBOX_RESPONSE_CODE_FIELD=21
42+
declare -gr SANDBOX_GUARANTEE_TYPE_FIELD=22
5143

5244
# HTTP Session Perf Log Globals:
5345
declare -ga HTTP_METRICS=(http_receive http_sent http_total)
@@ -59,110 +51,3 @@ declare -gA HTTP_METRICS_FIELDS=(
5951
declare -gr HTTP_TENANT_NAME_FIELD=1
6052
declare -gr HTTP_ROUTE_FIELD=2
6153
declare -gr HTTP_CPU_FREQ_FIELD=9
62-
63-
assert_run_experiments_args() {
64-
if (($# != 3)); then
65-
panic "invalid number of arguments \"$#\""
66-
return 1
67-
elif [[ -z "$1" ]]; then
68-
panic "hostname \"$1\" was empty"
69-
return 1
70-
elif [[ ! -d "$2" ]]; then
71-
panic "directory \"$2\" does not exist"
72-
return 1
73-
elif [[ -z "$3" ]]; then
74-
panic "load gen \"$3\" was empty"
75-
return 1
76-
fi
77-
}
78-
79-
assert_process_client_results_args() {
80-
if (($# != 1)); then
81-
error_msg "invalid number of arguments ($#, expected 1)"
82-
return 1
83-
elif ! [[ -d "$1" ]]; then
84-
error_msg "directory $1 does not exist"
85-
return 1
86-
fi
87-
}
88-
89-
assert_process_server_results_args() {
90-
if (($# != 1)); then
91-
panic "invalid number of arguments \"$#\""
92-
return 1
93-
elif [[ ! -d "$1" ]]; then
94-
panic "directory \"$1\" does not exist"
95-
return 1
96-
fi
97-
}
98-
99-
load_value() {
100-
local result=$1
101-
if [ "$result" = "?" ]; then
102-
result=$2
103-
fi
104-
echo "$result"
105-
}
106-
107-
run_init() {
108-
for var in "${VARYING[@]}"; do
109-
for t_idx in "${!TENANT_IDS[@]}"; do
110-
local tenant_id=${TENANT_IDS[$t_idx]}
111-
local tenant=$(printf "%s-%03d" "$tenant_id" "$var")
112-
local port=$((INIT_PORTS[t_idx]+var))
113-
local repl_period=$(load_value ${MTDS_REPL_PERIODS_us[$t_idx]} $var)
114-
local budget=$(load_value ${MTDS_MAX_BUDGETS_us[$t_idx]} $var)
115-
116-
# TENANTS+=("$tenant")
117-
ports+=([$tenant]=$port)
118-
repl_periods+=([$tenant]=$repl_period)
119-
max_budgets+=([$tenant]=$budget)
120-
121-
local t_routes r_expected_execs r_deadlines r_arg_opts_hey r_arg_opts_lt r_args r_loads
122-
123-
IFS=' ' read -r -a t_routes <<< "${ROUTES[$t_idx]}"
124-
IFS=' ' read -r -a r_wasm_paths <<< "${WASM_PATHS[$t_idx]}"
125-
IFS=' ' read -r -a r_expected_execs <<< "${EXPECTED_EXEC_TIMES_us[$t_idx]}"
126-
IFS=' ' read -r -a r_deadlines <<< "${DEADLINES_us[$t_idx]}"
127-
IFS=' ' read -r -a r_resp_content_types <<< "${RESP_CONTENT_TYPES[$t_idx]}"
128-
129-
IFS=' ' read -r -a r_arg_opts_hey <<< "${ARG_OPTS_HEY[$t_idx]}"
130-
IFS=' ' read -r -a r_arg_opts_lt <<< "${ARG_OPTS_LT[$t_idx]}"
131-
IFS=' ' read -r -a r_args <<< "${ARGS[$t_idx]}"
132-
IFS=' ' read -r -a r_loads <<< "${LOADS[$t_idx]}"
133-
134-
for r_idx in "${!t_routes[@]}"; do
135-
local route=${t_routes[$r_idx]}
136-
local wasm_path=${r_wasm_paths[$r_idx]}
137-
local expected=${r_expected_execs[$r_idx]}
138-
local deadline=${r_deadlines[$r_idx]}
139-
local resp_content_type=${r_resp_content_types[$r_idx]}
140-
local arg_opt_hey=${r_arg_opts_hey[$r_idx]}
141-
local arg_opt_lt=${r_arg_opts_lt[$r_idx]}
142-
local arg=${r_args[$r_idx]}
143-
local load=$(load_value ${r_loads[$r_idx]} $var)
144-
145-
local workload="$tenant-$route"
146-
147-
# Divide as float, cast the result to int (Loadtest is okay floats, HEY is not)
148-
local con=$(echo "x = $NWORKERS * $deadline / $expected * $load / 100; x/1" | bc)
149-
local rps=$((1000000 * con / deadline))
150-
# local rps=$(echo "x = 1000000 * $con / $deadline; x/1" | bc)
151-
152-
wasm_paths+=([$workload]=$wasm_path)
153-
expected_execs+=([$workload]=$expected)
154-
deadlines+=([$workload]=$deadline)
155-
resp_content_types+=([$workload]=$resp_content_type)
156-
arg_opts_hey+=([$workload]=$arg_opt_hey)
157-
arg_opts_lt+=([$workload]=$arg_opt_lt)
158-
args+=([$workload]=$arg)
159-
concurrencies+=([$workload]=$con)
160-
rpss+=([$workload]=$rps)
161-
workloads+=("$workload")
162-
workload_tids+=([$workload]=$tenant_id)
163-
workload_deadlines+=([$workload]=$deadline)
164-
workload_vars+=([$workload]=$var)
165-
done
166-
done
167-
done
168-
}

tests/bash_libraries/framework.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ __framework_sh__parse_arguments() {
164164
;;
165165
-n=* | --name=*)
166166
echo "Set experiment name to ${i#*=}"
167-
__framework_sh__experiment_name="${i#*=}"
167+
__framework_sh__experiment_name+=" ${i#*=}"
168168
shift
169169
;;
170170
-e=* | --envfile=*)
@@ -190,6 +190,9 @@ __framework_sh__parse_arguments() {
190190
__framework_sh__usage
191191
exit 0
192192
;;
193+
nuclio | Nuclio)
194+
echo "Running for Nuclio"
195+
;;
193196
*)
194197
echo "$1 is a not a valid option"
195198
__framework_sh__usage
@@ -199,7 +202,7 @@ __framework_sh__parse_arguments() {
199202
done
200203

201204
if [[ -z "$__framework_sh__envfile" ]]; then
202-
if [[ -d "$__framework_sh__application_directory/res/$__framework_sh__experiment_name/" ]]; then
205+
if [[ -d "$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/" ]]; then
203206
echo "Experiment $__framework_sh__experiment_name already exists. Pick a unique name!"
204207
exit 1
205208
fi
@@ -209,8 +212,8 @@ __framework_sh__parse_arguments() {
209212
exit 1
210213
fi
211214
short_name="$(basename "${__framework_sh__envfile/.env/}")"
212-
echo "$__framework_sh__application_directory/res/$__framework_sh__experiment_name/$short_name/"
213-
if [[ -d "$__framework_sh__application_directory/res/$__framework_sh__experiment_name/$short_name/" ]]; then
215+
echo "$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/$short_name/"
216+
if [[ -d "$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/$short_name/" ]]; then
214217
echo "Variant $short_name was already run in experiment ${__framework_sh__experiment_name}."
215218
exit 1
216219
fi
@@ -469,8 +472,8 @@ __framework_sh__run_both() {
469472
__framework_sh__create_and_export_results_directory() {
470473
local -r subdirectory=${1:-""}
471474

472-
local dir="$__framework_sh__application_directory/res/$__framework_sh__experiment_name"
473-
# local dir="$__framework_sh__application_directory/res/$__framework_sh__experiment_name/$subdirectory"
475+
local dir="$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name"
476+
# local dir="$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/$subdirectory"
474477

475478
mkdir -p "$dir" || {
476479
panic "mkdir -p $dir"

tests/bash_libraries/generate_spec_json.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
# shellcheck shell=bash
2-
# shellcheck disable=SC2154
2+
# shellcheck disable=SC2154,SC2155
33
if [ -n "$__generate_spec_json_sh__" ]; then return; fi
44
__generate_spec_json_sh__=$(date)
55

6+
jq_admin_spec() {
7+
jq ". + {\
8+
\"name\": \"Admin\",\
9+
\"port\": 55555,\
10+
\"replenishment-period-us\": 0,\
11+
\"max-budget-us\": 0,\
12+
\"reservation-percentile\": 0,\
13+
\"routes\": [\
14+
.routes[] + {\
15+
\"route\": \"/admin\",\
16+
\"admissions-percentile\": 50,\
17+
\"expected-execution-us\": 1000,\
18+
\"relative-deadline-us\": 10000},\
19+
.routes[] + {\
20+
\"route\": \"/terminator\",\
21+
\"admissions-percentile\": 50,\
22+
\"expected-execution-us\": 1000,\
23+
\"relative-deadline-us\": 10000}\
24+
]\
25+
}" < "./template.json" > "./result_admin.json"
26+
}
27+
628
generate_spec_json() {
729
printf "Generating 'spec.json'\n"
830

@@ -13,12 +35,14 @@ generate_spec_json() {
1335
local port=${ports[$tenant]}
1436
local repl_period=${repl_periods[$tenant]}
1537
local budget=${max_budgets[$tenant]}
38+
local reservation=${reservations[$tenant]}
1639

1740
jq_str=". + {
1841
\"name\": \"$tenant\",\
1942
\"port\": $port,\
2043
\"replenishment-period-us\": $repl_period,\
2144
\"max-budget-us\": $budget,\
45+
\"reservation-percentile\": $reservation,\
2246
\"routes\": ["
2347

2448
local t_routes

tests/bash_libraries/install_tools.sh

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/bin/bash
2+
3+
if ! command -v http > /dev/null; then
4+
if [[ $(whoami) == "root" ]]; then
5+
apt update
6+
apt install -y httpie
7+
else
8+
sudo apt update
9+
sudo apt install -y httpie
10+
fi
11+
fi
12+
13+
if ! command -v hey > /dev/null; then
14+
HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64
15+
wget $HEY_URL -O hey
16+
chmod +x hey
17+
18+
if [[ $(whoami) == "root" ]]; then
19+
mv hey /usr/bin/hey
20+
else
21+
sudo mv hey /usr/bin/hey
22+
fi
23+
fi
24+
25+
if ! command -v loadtest > /dev/null; then
26+
if ! command -v npm > /dev/null; then
27+
# if [[ $(whoami) == "root" ]]; then
28+
# apt update
29+
# apt install -y npm
30+
# else
31+
# sudo apt update
32+
# sudo apt install -y npm
33+
# fi
34+
# installs NVM (Node Version Manager)
35+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
36+
export NVM_DIR="$HOME/.nvm"
37+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
38+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
39+
# download and install Node.js
40+
nvm install 14
41+
# verifies the right Node.js version is in the environment
42+
node -v # should print `v14.21.3`
43+
# verifies the right NPM version is in the environment
44+
npm -v # should print `6.14.18`
45+
fi
46+
47+
# Try pulling Emil's version of loadtest to support post binary files
48+
# if [[ $(whoami) == "root" ]]; then
49+
# npm install -y -g loadtest
50+
# else
51+
# sudo npm install -y -g loadtest
52+
# fi
53+
54+
pushd ~
55+
git clone https://github.com/emil916/loadtest.git
56+
pushd loadtest
57+
# if [[ $(whoami) == "root" ]]; then
58+
npm install -g
59+
# else
60+
# sudo npm install -g
61+
# fi
62+
popd
63+
popd
64+
fi
65+
66+
if ! command -v gnuplot > /dev/null; then
67+
if [[ $(whoami) == "root" ]]; then
68+
apt update
69+
apt install -y gnuplot
70+
else
71+
sudo apt update
72+
sudo apt install -y gnuplot
73+
fi
74+
fi
75+
76+
77+
if ! command -v jq > /dev/null; then
78+
if [[ $(whoami) == "root" ]]; then
79+
apt update
80+
apt install -y jq
81+
else
82+
sudo apt update
83+
sudo apt install -y jq
84+
fi
85+
fi
86+
87+
if ! command -v htop > /dev/null; then
88+
if [[ $(whoami) == "root" ]]; then
89+
apt update
90+
apt install -y htop
91+
else
92+
sudo apt update
93+
sudo apt install -y htop
94+
fi
95+
fi
96+
97+
# For SOD:
98+
# if ! command -v imagemagick > /dev/null; then
99+
# if [ "$(whoami)" == "root" ]; then
100+
# apt-get install -y imagemagick
101+
# else
102+
# sudo apt-get install -y imagemagick
103+
# fi
104+
# fi
105+
106+
# For GOCR, too many to check one-by-one, so uncomment below to install:
107+
# if [[ "$(whoami)" == "root" ]]; then
108+
# apt-get install -y netpbm pango1.0-tools wamerican fonts-roboto fonts-cascadia-code fonts-dejavu
109+
# else
110+
# sudo apt-get install -y netpbm pango1.0-tools wamerican fonts-roboto fonts-cascadia-code fonts-dejavu
111+
# fi
112+
113+
source ~/.bashrc

0 commit comments

Comments
 (0)