You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.0 KiB

#!/bin/bash
__run_sh__base_path="$(dirname "$(realpath --logical "${BASH_SOURCE[0]}")")"
__run_sh__bash_libraries_relative_path="../../bash_libraries"
__run_sh__bash_libraries_absolute_path=$(cd "$__run_sh__base_path" && cd "$__run_sh__bash_libraries_relative_path" && pwd)
export PATH="$__run_sh__bash_libraries_absolute_path:$PATH"
source csv_to_dat.sh || exit 1
source framework.sh || exit 1
source get_result_count.sh || exit 1
source panic.sh || exit 1
source path_join.sh || exit 1
source percentiles_table.sh || exit 1
source validate_dependencies.sh || exit 1
get_random_image() {
local -n __random_image="$1"
__random_image="${cifar10_images[$((RANDOM % ${#cifar10_images[@]}))]}"
}
run_functional_tests() {
local hostname="$1"
local results_directory="$2"
printf "Func Tests: \n"
# Functional Testing on each image
for image in "${cifar10_images[@]}"; do
echo "${image}" >> "${results_directory}/cifar10_rand.txt"
curl --data-binary "@${image}" -s "${hostname}:10000/rand" >> "${results_directory}/cifar10_rand.txt"
done
echo "$same_image" >> "${results_directory}/cifar10_same.txt"
curl --data-binary "@$same_image" -s "${hostname}:10000/same" >> "${results_directory}/cifar10_same.txt"
printf "[OK]\n"
}
run_perf_tests() {
local hostname="$1"
local results_directory="$2"
local -ir total_iterations=100
local -ir worker_max=10
local -ir batch_size=10
local -i batch_id=0
local image
local pids
printf "Perf Tests: \n"
for workload in "${workloads[@]}"; do
batch_id=0
for ((i = 0; i < total_iterations; i += batch_size)); do
# Block waiting for a worker to finish if we are at our max
while (($(pgrep --count hey) >= worker_max)); do
wait -n "$(pgrep hey | tr '\n' ' ')"
done
((batch_id++))
if [ "$workload" = "cifar10_rand" ]; then
get_random_image image
else
image=$same_image
fi
hey -disable-compression -disable-keepalive -disable-redirects -n $batch_size -c 1 -cpus 1 -t 0 -o csv -m POST -D "${image}" "http://${hostname}:10000${route[$workload]}" > "$results_directory/${workload}_${batch_id}.csv" 2> /dev/null &
done
pids=$(pgrep hey | tr '\n' ' ')
[[ -n $pids ]] && wait -f $pids
done
printf "[OK]\n"
for workload in "${workloads[@]}"; do
tail --quiet -n +2 "$results_directory/${workload}"_*.csv >> "$results_directory/${workload}.csv"
rm "$results_directory/${workload}"_*.csv
done
}
# Process the experimental results and generate human-friendly results for success rate, throughput, and latency
process_results() {
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
local -r results_directory="$1"
printf "Processing Results: \n"
# Write headers to CSVs
percentiles_table_header "$results_directory/latency.csv"
for workload in "${workloads[@]}"; do
# Filter on 200s, subtract DNS time, convert from s to ms, and sort
awk -F, '$7 == 200 {print (($1 - $2) * 1000)}' < "$results_directory/$workload.csv" \
| sort -g > "$results_directory/$workload-response.csv"
percentiles_table_row "$results_directory/$workload-response.csv" "$results_directory/latency.csv" "$workload"
# Delete scratch file used for sorting/counting
rm -rf "$results_directory/$workload-response.csv"
done
# Transform csvs to dat files for gnuplot
csv_to_dat "$results_directory/latency.csv"
printf "[OK]\n"
return 0
}
experiment_client() {
local -r hostname="$1"
local -r results_directory="$2"
local same_image # for the cifar10_same workload
get_random_image same_image
run_functional_tests "$hostname" "$results_directory" || return 1
run_perf_tests "$hostname" "$results_directory" || return 1
process_results "$results_directory" || return 1
}
validate_dependencies curl
declare -ar workloads=(cifar10_rand cifar10_same)
declare -Ar route=(
[cifar10_rand]=/rand
[cifar10_same]=/same
)
# Sort the images by the number of labeled plates
WIP: WASI Support (#267) * feat: Preliminary WASI with fib workload * refactor: Clarify initialize globals * chore: Update empty to WASI * chore: cleanup fib test * chore: cleanup build tooling * chore: cleanup test Makefiles and some nits * chore: Update LLVM and install WASI-SDK * chore: Update build tools and specs * docs: Update example module spec in README * refactor: Clean up HTTP handling * feat: Implement exit WASI call * style: apply clang-format * ci: rewrite compile sledge step * build: Remove LLVM install shims * build: Try manually adding libunwind * build: Try adding libunwind-dev * ci: break out aWsm compile step * fix: Correct test build error * fix: Correct error in WASI fd_write * chore: Increase gocr http buffer size * test: Correct image resize test * chore: Remove zombie wasmception functions * chore: Reduce dummy args to single arg * chore: Add debugging makefile fivebyeight * chore: Remove erronious PHONYs in tests Makefile * ci: Disable gocr tests * chore: Add wat Make rule to fibonacci test * chore: fix apt package name * chore: Enable clean of failed ck install * chore: use LLVM 12 * test: Disable gocr tests * chore: Enhance test makefile * chore: Add CFILES as sledgert dep * chore: Add NULL check for function table pointer * chore: Add missing header * chore: uncomment cleanup in imageresize test * refactor: Remove unused linear memory functions * build: Add bimodal debug makefile * chore: Add linear memory debug logs * refactor: Cleanup region initialization * build: Correct PHONY in runtime Makefile * chore: deb install script for outside of container * refactor: Remove zombie extern. * feat: WebAssembly traps * refactor: Use C18 features * chore: Remove git diff annotations * fix: tweaks to run all sample apps with WASI * test: convert shell script to Makefile * build: clean generated ck Makefile * chore: Use awsm branch with fixes * chore: Revert name changes * fix: Correct type issues * refactor: Reverse additional name change * refactor: Remove awsm compat shims * chore: Remove libc association * build: Better detect header file changes * refactor: current_wasm_module_instance_trap * test: reenable tests * chore: Delete copied script * build: Fix test workloads * fix: Implement HTTP 500 * fix: Protect against overflow on comparison * build: Replace test.sh with makefile * refactor: blow away tmp directory conflicts * refactor: centralize wasm in single submodule * feat: libsledge and sledge ABI * chore: move tests * refactor: tests * chore: update wasm_apps with new sample data * doc: Initial ABI README * feat: globals table * docs: Merge aWsm ABI docs * docs: libsledge ABI * build: rename apps to keep consistent * build: Disable wasm proposals * build: Update wasm apps and fix typo * test: test makefiles * test: Additional test makefiles * build: top-level build and install rules wo Docker * docs: Add wasm lld comment * build: top level makefile * chore: merge debug flags * fix: Correct out of bounds error * feat: indirection to awsm ABI * fix: Correct link hack with proper flag * fix: gps typo * chore: format nit * ci: update makefile rules * ci: check WASI_SDK_PATH * fix: Adjust paths * ci: fix make rule name * refactor: Attempt to use generic vec * refactor: Remove type-specific vec * fix: Resolve assorted TODOs * chore: fix clang format issue * ci: Invalidate app cache on libsledge changes * fix: Correct wasm trap check * fix: free wasm globals * docs: example of running top level tests via make * chore: option to log unsupported wasi * test: add preempt client generator for fib bimodal * refactor: Allocate wasm memory with 4096 align * fix: Handle build without runtime globals * refactor: bypass runtime call for first global * fix: Correct sandbox logging * test: fix incorrect paths in test.mk * refactor: remove wasm traps * refactor: Revert additional traps and changes * refactor: Remove additional traps * refactor: Disable exit support * fix: block preemption in memory allocation * feat: wasm g0 write back * build: cleanup applications Makefile * chore: Reorder bash variables * docs: Add comment explaining LOG_SANDBOX_STDERR * fix: Remove tracking of nonpreemptive siglarms * chore: Validate Linux, C, and POSIX requirements * build: Dry up libsledge makefile * refactor: Remove unused macros * fix: Writeback global 0 on cooperative sched * refactor: Fork WASI from aWsm uvwasi example * build: remove awsm-wasi rules * chore: clang-format 15 * ci: apt update * chore: clang 13 * ci: use llvm script * ci: Use LLVM 13 * refactor: Remove WASI indirection
3 years ago
declare -a cifar10_images=(../../../applications/wasm_apps/CMSIS_5_NN/images/bmp/*)
framework_init "$@"