Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Bash scripts #384

Merged
merged 5 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
{
"configurations": [
{
"name": "Linux",
"intelliSenseMode": "clang-x64",
"includePath": [
"/usr/include/",
"${workspaceFolder}/runtime/include/",
"${workspaceFolder}/runtime/thirdparty/ck/include/",
"${workspaceFolder}/runtime/thirdparty/http-parser/",
"${workspaceFolder}/runtime/thirdparty/jsmn/",
"${workspaceFolder}/awsm/runtime/libc/wasi/include/",
"${workspaceFolder}/libsledge/include"
],
"defines": [
"x86_64",
"_GNU_SOURCE"
],
"cStandard": "c17",
"compilerPath": "/usr/bin/clang"
}
],
"version": 4
}
"configurations": [
{
"name": "Linux",
"intelliSenseMode": "clang-x64",
"includePath": [
"/usr/include/",
"${workspaceFolder}/runtime/include/",
"${workspaceFolder}/runtime/thirdparty/ck/include/",
"${workspaceFolder}/runtime/thirdparty/http-parser/",
"${workspaceFolder}/runtime/thirdparty/jsmn/",
"${workspaceFolder}/awsm/runtime/libc/wasi/include/",
"${workspaceFolder}/libsledge/include"
],
"defines": [
"x86_64",
"_GNU_SOURCE"
],
"cStandard": "c17"
}
],
"version": 4
}
24 changes: 21 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,25 @@
"local_cleanup_queue.h": "c",
"sandbox_state_transition.h": "c",
"http_session_perf_log.h": "c",
"perf_window.h": "c",
"global_request_scheduler_deque.h": "c"
"traffic_control.h": "c",
"memory_resource": "c",
"memory": "c",
"istream": "c",
"ostream": "c",
"sstream": "c",
"streambuf": "c",
"sandbox_perf_log.h": "c",
"global_request_scheduler_deque.h": "c",
"message.h": "c",
"dbf.h": "c",
"dbf_generic.h": "c",
"tenant_functions.h": "c",
"thread": "c",
"limits": "c",
"algorithm": "c",
"stdio.h": "c",
"get_time.h": "c",
"unistd.h": "c"
},
"files.exclude": {
"**/.git": true,
Expand Down Expand Up @@ -189,5 +206,6 @@
"TKILL",
"WASI"
],
"C_Cpp.errorSquiggles": "Enabled"
"C_Cpp.errorSquiggles": "Enabled",
"C_Cpp.default.compilerPath": "/usr/bin/clang"
}
2 changes: 1 addition & 1 deletion awsm
Submodule awsm updated 141 files
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
res
res-*
perf.data
perf.data.old
samples
Expand Down
135 changes: 10 additions & 125 deletions tests/bash_libraries/experiment_globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,20 @@
if [ -n "$__experiment_server_globals_sh__" ]; then return; fi
__experiment_server_globals_sh__=$(date)

# App WASM so files:
declare -r FIBONACCI="fibonacci.wasm.so"
declare -r EKF="gps_ekf.wasm.so"
declare -r CIFAR10="cifar10.wasm.so"
declare -r GOCR="gocr.wasm.so"
declare -r LPD="license_plate_detection.wasm.so"
declare -r RESIZE="resize_image.wasm.so"
declare -r CNN="cnn_face_detection.wasm.so"

# The global configs for the scripts
declare -gr SERVER_LOG_FILE="perf.log"
declare -gr SERVER_HTTP_LOG_FILE="http_perf.log"
declare -gr HEY_OPTS="-disable-compression -disable-keepalive -disable-redirects"

# Globals to fill during run_init in run.sh, to use in base and generate_spec
declare -A ports=()
declare -A repl_periods=()
declare -A max_budgets=()
declare -A wasm_paths=()
declare -A expected_execs=()
declare -A deadlines=()
declare -A resp_content_types=()
declare -A arg_opts_hey=()
declare -A arg_opts_lt=()
declare -A args=()
declare -A concurrencies=()
declare -A rpss=()
declare -a workloads=()
declare -A workload_tids=()
declare -A workload_deadlines=()
declare -A workload_vars=()

# Sandbox Perf Log Globals:
declare -ga SANDBOX_METRICS=(total queued uninitialized allocated initialized runnable interrupted preempted running_sys running_user asleep returned complete error)
declare -gA SANDBOX_METRICS_FIELDS=(
Expand All @@ -48,6 +39,7 @@ declare -gr SANDBOX_TENANT_NAME_FIELD=2
declare -gr SANDBOX_ROUTE_FIELD=3
declare -gr SANDBOX_CPU_FREQ_FIELD=20
declare -gr SANDBOX_RESPONSE_CODE_FIELD=21
declare -gr SANDBOX_GUARANTEE_TYPE_FIELD=22

# HTTP Session Perf Log Globals:
declare -ga HTTP_METRICS=(http_receive http_sent http_total)
Expand All @@ -59,110 +51,3 @@ declare -gA HTTP_METRICS_FIELDS=(
declare -gr HTTP_TENANT_NAME_FIELD=1
declare -gr HTTP_ROUTE_FIELD=2
declare -gr HTTP_CPU_FREQ_FIELD=9

assert_run_experiments_args() {
if (($# != 3)); then
panic "invalid number of arguments \"$#\""
return 1
elif [[ -z "$1" ]]; then
panic "hostname \"$1\" was empty"
return 1
elif [[ ! -d "$2" ]]; then
panic "directory \"$2\" does not exist"
return 1
elif [[ -z "$3" ]]; then
panic "load gen \"$3\" was empty"
return 1
fi
}

assert_process_client_results_args() {
if (($# != 1)); then
error_msg "invalid number of arguments ($#, expected 1)"
return 1
elif ! [[ -d "$1" ]]; then
error_msg "directory $1 does not exist"
return 1
fi
}

assert_process_server_results_args() {
if (($# != 1)); then
panic "invalid number of arguments \"$#\""
return 1
elif [[ ! -d "$1" ]]; then
panic "directory \"$1\" does not exist"
return 1
fi
}

load_value() {
local result=$1
if [ "$result" = "?" ]; then
result=$2
fi
echo "$result"
}

run_init() {
for var in "${VARYING[@]}"; do
for t_idx in "${!TENANT_IDS[@]}"; do
local tenant_id=${TENANT_IDS[$t_idx]}
local tenant=$(printf "%s-%03d" "$tenant_id" "$var")
local port=$((INIT_PORTS[t_idx]+var))
local repl_period=$(load_value ${MTDS_REPL_PERIODS_us[$t_idx]} $var)
local budget=$(load_value ${MTDS_MAX_BUDGETS_us[$t_idx]} $var)

# TENANTS+=("$tenant")
ports+=([$tenant]=$port)
repl_periods+=([$tenant]=$repl_period)
max_budgets+=([$tenant]=$budget)

local t_routes r_expected_execs r_deadlines r_arg_opts_hey r_arg_opts_lt r_args r_loads

IFS=' ' read -r -a t_routes <<< "${ROUTES[$t_idx]}"
IFS=' ' read -r -a r_wasm_paths <<< "${WASM_PATHS[$t_idx]}"
IFS=' ' read -r -a r_expected_execs <<< "${EXPECTED_EXEC_TIMES_us[$t_idx]}"
IFS=' ' read -r -a r_deadlines <<< "${DEADLINES_us[$t_idx]}"
IFS=' ' read -r -a r_resp_content_types <<< "${RESP_CONTENT_TYPES[$t_idx]}"

IFS=' ' read -r -a r_arg_opts_hey <<< "${ARG_OPTS_HEY[$t_idx]}"
IFS=' ' read -r -a r_arg_opts_lt <<< "${ARG_OPTS_LT[$t_idx]}"
IFS=' ' read -r -a r_args <<< "${ARGS[$t_idx]}"
IFS=' ' read -r -a r_loads <<< "${LOADS[$t_idx]}"

for r_idx in "${!t_routes[@]}"; do
local route=${t_routes[$r_idx]}
local wasm_path=${r_wasm_paths[$r_idx]}
local expected=${r_expected_execs[$r_idx]}
local deadline=${r_deadlines[$r_idx]}
local resp_content_type=${r_resp_content_types[$r_idx]}
local arg_opt_hey=${r_arg_opts_hey[$r_idx]}
local arg_opt_lt=${r_arg_opts_lt[$r_idx]}
local arg=${r_args[$r_idx]}
local load=$(load_value ${r_loads[$r_idx]} $var)

local workload="$tenant-$route"

# Divide as float, cast the result to int (Loadtest is okay floats, HEY is not)
local con=$(echo "x = $NWORKERS * $deadline / $expected * $load / 100; x/1" | bc)
local rps=$((1000000 * con / deadline))
# local rps=$(echo "x = 1000000 * $con / $deadline; x/1" | bc)

wasm_paths+=([$workload]=$wasm_path)
expected_execs+=([$workload]=$expected)
deadlines+=([$workload]=$deadline)
resp_content_types+=([$workload]=$resp_content_type)
arg_opts_hey+=([$workload]=$arg_opt_hey)
arg_opts_lt+=([$workload]=$arg_opt_lt)
args+=([$workload]=$arg)
concurrencies+=([$workload]=$con)
rpss+=([$workload]=$rps)
workloads+=("$workload")
workload_tids+=([$workload]=$tenant_id)
workload_deadlines+=([$workload]=$deadline)
workload_vars+=([$workload]=$var)
done
done
done
}
15 changes: 9 additions & 6 deletions tests/bash_libraries/framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ __framework_sh__parse_arguments() {
;;
-n=* | --name=*)
echo "Set experiment name to ${i#*=}"
__framework_sh__experiment_name="${i#*=}"
__framework_sh__experiment_name+=" ${i#*=}"
shift
;;
-e=* | --envfile=*)
Expand All @@ -190,6 +190,9 @@ __framework_sh__parse_arguments() {
__framework_sh__usage
exit 0
;;
nuclio | Nuclio)
echo "Running for Nuclio"
;;
*)
echo "$1 is a not a valid option"
__framework_sh__usage
Expand All @@ -199,7 +202,7 @@ __framework_sh__parse_arguments() {
done

if [[ -z "$__framework_sh__envfile" ]]; then
if [[ -d "$__framework_sh__application_directory/res/$__framework_sh__experiment_name/" ]]; then
if [[ -d "$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/" ]]; then
echo "Experiment $__framework_sh__experiment_name already exists. Pick a unique name!"
exit 1
fi
Expand All @@ -209,8 +212,8 @@ __framework_sh__parse_arguments() {
exit 1
fi
short_name="$(basename "${__framework_sh__envfile/.env/}")"
echo "$__framework_sh__application_directory/res/$__framework_sh__experiment_name/$short_name/"
if [[ -d "$__framework_sh__application_directory/res/$__framework_sh__experiment_name/$short_name/" ]]; then
echo "$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/$short_name/"
if [[ -d "$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/$short_name/" ]]; then
echo "Variant $short_name was already run in experiment ${__framework_sh__experiment_name}."
exit 1
fi
Expand Down Expand Up @@ -469,8 +472,8 @@ __framework_sh__run_both() {
__framework_sh__create_and_export_results_directory() {
local -r subdirectory=${1:-""}

local dir="$__framework_sh__application_directory/res/$__framework_sh__experiment_name"
# local dir="$__framework_sh__application_directory/res/$__framework_sh__experiment_name/$subdirectory"
local dir="$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name"
# local dir="$__framework_sh__application_directory/res-$__framework_sh__role/$__framework_sh__experiment_name/$subdirectory"

mkdir -p "$dir" || {
panic "mkdir -p $dir"
Expand Down
26 changes: 25 additions & 1 deletion tests/bash_libraries/generate_spec_json.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
# shellcheck shell=bash
# shellcheck disable=SC2154
# shellcheck disable=SC2154,SC2155
if [ -n "$__generate_spec_json_sh__" ]; then return; fi
__generate_spec_json_sh__=$(date)

jq_admin_spec() {
jq ". + {\
\"name\": \"Admin\",\
\"port\": 55555,\
\"replenishment-period-us\": 0,\
\"max-budget-us\": 0,\
\"reservation-percentile\": 0,\
\"routes\": [\
.routes[] + {\
\"route\": \"/admin\",\
\"admissions-percentile\": 50,\
\"expected-execution-us\": 1000,\
\"relative-deadline-us\": 10000},\
.routes[] + {\
\"route\": \"/terminator\",\
\"admissions-percentile\": 50,\
\"expected-execution-us\": 1000,\
\"relative-deadline-us\": 10000}\
]\
}" < "./template.json" > "./result_admin.json"
}

generate_spec_json() {
printf "Generating 'spec.json'\n"

Expand All @@ -13,12 +35,14 @@ generate_spec_json() {
local port=${ports[$tenant]}
local repl_period=${repl_periods[$tenant]}
local budget=${max_budgets[$tenant]}
local reservation=${reservations[$tenant]}

jq_str=". + {
\"name\": \"$tenant\",\
\"port\": $port,\
\"replenishment-period-us\": $repl_period,\
\"max-budget-us\": $budget,\
\"reservation-percentile\": $reservation,\
\"routes\": ["

local t_routes
Expand Down
Loading
Loading