From 21d0f2857230b954d27967cc0d1c369a8d609b4f Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 8 Apr 2021 17:50:01 +0000 Subject: [PATCH 01/14] chore: Fix missing csv comma --- runtime/include/sandbox.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/include/sandbox.h b/runtime/include/sandbox.h index 885cb32..6d3d940 100644 --- a/runtime/include/sandbox.h +++ b/runtime/include/sandbox.h @@ -277,7 +277,7 @@ sandbox_summarize_page_allocations(struct sandbox *sandbox) FILE *sandbox_page_allocations_log = fopen(sandbox_page_allocations_log_path, "a"); - fprintf(sandbox_page_allocations_log, "%lu,%lu,%s", sandbox->id, sandbox->running_duration, + fprintf(sandbox_page_allocations_log, "%lu,%lu,%s,", sandbox->id, sandbox->running_duration, sandbox_state_stringify(sandbox->state)); for (size_t i = 0; i < sandbox->page_allocation_timestamps_size; i++) fprintf(sandbox_page_allocations_log, "%u,", sandbox->page_allocation_timestamps[i]); From 69d7a8ae8d5969a11a784ff293a0548cc9d43609 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 8 Apr 2021 20:01:38 -0400 Subject: [PATCH 02/14] chore: add missing utils --- Dockerfile.x86_64 | 59 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 index e535590..f588f17 100644 --- a/Dockerfile.x86_64 +++ b/Dockerfile.x86_64 @@ -9,24 +9,25 @@ RUN apt-get update # pkg-config, libtool - used by PocketSphinx # cmake - used by cmsis RUN apt-get install -y --no-install-recommends \ - automake \ - build-essential \ - binutils-dev \ - cmake \ - git \ - libtinfo5 \ - libtool \ - pkg-config + automake \ + bsdmainutils \ + build-essential \ + binutils-dev \ + cmake \ + git \ + libtinfo5 \ + libtool \ + pkg-config # Needed to install from http endpoints via curl or wget RUN apt-get install -y --no-install-recommends \ - curl \ - ca-certificates \ - libssl-dev \ - lsb-release \ - gpg-agent \ - software-properties-common \ - wget + curl \ + ca-certificates \ + libssl-dev \ + lsb-release \ + gpg-agent \ + software-properties-common \ + wget # LLVM Tools ENV LLVM_VERSION=8 @@ -44,20 +45,24 @@ ENV WASI_SDK=/opt/wasi-sdk # Test Script Stuff RUN apt-get install -y --no-install-recommends \ - fonts-dejavu \ - fonts-cascadia-code \ - fonts-roboto \ - imagemagick \ - netpbm \ - pango1.0-tools \ - wamerican + fonts-dejavu \ + fonts-cascadia-code \ + fonts-roboto \ + imagemagick \ + netpbm \ + pango1.0-tools \ + wamerican + +# Hey is a load generator we have to recklessly download from the 'net, as it is only published to brew +# See https://github.com/rakyll/hey +RUN wget https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 && mv hey_linux_amd64 hey && chmod +x hey && mv hey /usr/bin/hey # Interactive Tools RUN apt-get install -y --no-install-recommends \ - less \ - gdb \ - strace \ - vim + less \ + gdb \ + strace \ + vim # We need to set the locale for pango-view ENV LANG C.UTF-8 @@ -76,7 +81,7 @@ ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH # # Create the user and add to sudoers # RUN groupadd --gid $USER_GID $USERNAME -# RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME +# RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME # RUN apt-get update && apt-get install -y sudo # RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ # RUN chmod 0440 /etc/sudoers.d/$USERNAME From da60ec8c8b140675ab4c905cac4241328abb6239 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 8 Apr 2021 20:06:55 -0400 Subject: [PATCH 03/14] chore: Add script to fix dev container root issues --- fix_root.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 fix_root.sh diff --git a/fix_root.sh b/fix_root.sh new file mode 100755 index 0000000..b786395 --- /dev/null +++ b/fix_root.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Currently, the build container still used root. This results in files owned by root that interfere with running things outside of the container. Pending additional tooling work, this script is a stop gap that searches and chowns all files in the proeject tree owned by root + +if [[ $(whoami) == "root" ]]; then + echo "Should not be run as root" + exit 1 +fi + +# Uses your host username and its primary associated group +username="$(whoami)" +group="$(id -g -n "$username")" + +while read -r file; do + echo sudo chown "$username":"$group" "$file" + sudo chown "$username":"$group" "$file" +done < <(find ~+ -type f -user root) From 124d1180bdc50dbb7f1e2ca46e2325641240d430 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 01:50:55 +0000 Subject: [PATCH 04/14] chore: Cleanup dl error handling --- runtime/src/main.c | 2 +- runtime/src/module.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/runtime/src/main.c b/runtime/src/main.c index 34d9500..7411dd6 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -363,7 +363,7 @@ main(int argc, char **argv) #ifdef LOG_MODULE_LOADING debuglog("Parsing modules file [%s]\n", argv[1]); #endif - if (module_new_from_json(argv[1])) panic("failed to parse modules file[%s]\n", argv[1]); + if (module_new_from_json(argv[1])) panic("failed to initialize module(s) defined in %s\n", argv[1]); runtime_start_runtime_worker_threads(); listener_thread_initialize(); diff --git a/runtime/src/module.c b/runtime/src/module.c index 9a9a49d..8f0a5ea 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -150,38 +150,42 @@ module_new(char *name, char *path, int32_t argument_count, uint32_t stack_size, /* Load the dynamic library *.so file with lazy function call binding and deep binding */ module->dynamic_library_handle = dlopen(path, RTLD_LAZY | RTLD_DEEPBIND); if (module->dynamic_library_handle == NULL) { - fprintf(stderr, "Failed to open dynamic library at %s: %s\n", path, dlerror()); + fprintf(stderr, "Failed to open %s with error: %s\n", path, dlerror()); goto dl_open_error; }; /* Resolve the symbols in the dynamic library *.so file */ module->main = (mod_main_fn_t)dlsym(module->dynamic_library_handle, MODULE_MAIN); if (module->main == NULL) { - fprintf(stderr, "Failed to resolve symbol %s: %s\n", MODULE_MAIN, dlerror()); + fprintf(stderr, "Failed to resolve symbol %s in %s with error: %s\n", MODULE_MAIN, path, dlerror()); goto dl_error; } module->initialize_globals = (mod_glb_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_GLOBALS); if (module->initialize_globals == NULL) { - fprintf(stderr, "Failed to resolve symbol %s: %s\n", MODULE_INITIALIZE_GLOBALS, dlerror()); + fprintf(stderr, "Failed to resolve symbol %s in %s with error: %s\n", MODULE_INITIALIZE_GLOBALS, path, + dlerror()); goto dl_error; } module->initialize_memory = (mod_mem_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_MEMORY); if (module->initialize_memory == NULL) { - fprintf(stderr, "Failed to resolve symbol %s: %s\n", MODULE_INITIALIZE_MEMORY, dlerror()); + fprintf(stderr, "Failed to resolve symbol %s in %s with error: %s\n", MODULE_INITIALIZE_MEMORY, path, + dlerror()); goto dl_error; }; module->initialize_tables = (mod_tbl_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_TABLE); if (module->initialize_tables == NULL) { - fprintf(stderr, "Failed to resolve symbol %s: %s\n", MODULE_INITIALIZE_TABLE, dlerror()); + fprintf(stderr, "Failed to resolve symbol %s in %s with error: %s\n", MODULE_INITIALIZE_TABLE, path, + dlerror()); goto dl_error; }; module->initialize_libc = (mod_libc_fn_t)dlsym(module->dynamic_library_handle, MODULE_INITIALIZE_LIBC); if (module->initialize_libc == NULL) { - fprintf(stderr, "Failed to resolve symbol %s: %s\n", MODULE_INITIALIZE_LIBC, dlerror()); + fprintf(stderr, "Failed to resolve symbol %s in %s with error: %s\n", MODULE_INITIALIZE_LIBC, path, + dlerror()); goto dl_error; } From 6b4ad005ff2e874cb973a8059406e70e8e061d88 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 01:51:26 +0000 Subject: [PATCH 05/14] chore: Add more missing test deps --- Dockerfile.x86_64 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 index f588f17..7944f77 100644 --- a/Dockerfile.x86_64 +++ b/Dockerfile.x86_64 @@ -10,7 +10,6 @@ RUN apt-get update # cmake - used by cmsis RUN apt-get install -y --no-install-recommends \ automake \ - bsdmainutils \ build-essential \ binutils-dev \ cmake \ @@ -59,6 +58,8 @@ RUN wget https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 && mv he # Interactive Tools RUN apt-get install -y --no-install-recommends \ + bc \ + bsdmainutils \ less \ gdb \ strace \ From 06b717ec4a858353205da1b800238983592b2650 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 01:52:17 +0000 Subject: [PATCH 06/14] fix: Add missing awsm parameters --- runtime/tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/tests/Makefile b/runtime/tests/Makefile index 7634e6f..65edc8f 100644 --- a/runtime/tests/Makefile +++ b/runtime/tests/Makefile @@ -36,7 +36,7 @@ sod: @mkdir -p ${TMP_DIR} @echo "Compiling $(@:%_rt=%)" ${WASMCC} ${$(@:%_rt=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} $(@:%_rt=%)/*.c $(AWSM_DUMMY) -o ${TMP_DIR}/$(@:%_rt=%).wasm - ${AWSM_NAME} ${TMP_DIR}/$(@:%_rt=%).wasm -o ${TMP_DIR}/$(@:%_rt=%).bc + ${AWSM_NAME} --inline-constant-globals --runtime-globals ${TMP_DIR}/$(@:%_rt=%).wasm -o ${TMP_DIR}/$(@:%_rt=%).bc ${CC} --shared -fPIC ${OPTFLAGS} -I${SLEDGE_RT_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${SLEDGE_MEMC} ${SLEDGE_WASMISA} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.so @cp ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${SLEDGE_BIN_DIR} # @rm -rf ${TMP_DIR} From 741051f8a6f01b77c9cbd0b0ce1c3e62ce40466d Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 01:53:06 +0000 Subject: [PATCH 07/14] chore: Add preemption to debug launch JSON --- .vscode/launch.json | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b0d9dc7..cc566d0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,11 +5,35 @@ "version": "0.2.0", "configurations": [ { - "name": "(gdb) Launch", + "name": "Hyde", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/runtime/bin/sledgert", - "args": ["${workspaceFolder}/runtime/experiments/applications/ocr/hyde/spec.json"], + "args": [ + "${workspaceFolder}/runtime/experiments/applications/ocr/hyde/spec.json" + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "envFile": "${workspaceFolder}/.env", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + }, + { + "name": "Preemption", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/runtime/bin/sledgert", + "args": [ + "${workspaceFolder}/runtime/experiments/preemption/spec.json" + ], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], From 8e027bb47e0aab981735ea8c26f30d763622a7fe Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 10:28:23 -0400 Subject: [PATCH 08/14] chore: improve fix_root script --- fix_root.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fix_root.sh b/fix_root.sh index b786395..fc19bb7 100755 --- a/fix_root.sh +++ b/fix_root.sh @@ -6,6 +6,11 @@ if [[ $(whoami) == "root" ]]; then exit 1 fi +if [[ $(pwd) == "/" ]]; then + echo "Should not be run from root directory" + exit 1 +fi + # Uses your host username and its primary associated group username="$(whoami)" group="$(id -g -n "$username")" @@ -13,4 +18,4 @@ group="$(id -g -n "$username")" while read -r file; do echo sudo chown "$username":"$group" "$file" sudo chown "$username":"$group" "$file" -done < <(find ~+ -type f -user root) +done < <(find ~+ -type f,d -user root) From c01ca7385064d63bbd4e3fd41bde958cb17cbcbb Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 9 Apr 2021 10:29:01 -0400 Subject: [PATCH 09/14] feat: working non-root dev container --- Dockerfile.x86_64 | 98 +++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 index 7944f77..c268ca4 100644 --- a/Dockerfile.x86_64 +++ b/Dockerfile.x86_64 @@ -2,13 +2,14 @@ FROM ubuntu:focal ARG DEBIAN_FRONTEND=noninteractive - -RUN apt-get update +ARG HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 +ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk_8.0_amd64.deb +ARG WASMCEPTION_URL=https://github.com/gwsystems/wasmception/releases/download/v0.2.0/wasmception-linux-x86_64-0.2.0.tar.gz # General GCC C/C++ Build toolchain # pkg-config, libtool - used by PocketSphinx # cmake - used by cmsis -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ automake \ build-essential \ binutils-dev \ @@ -19,7 +20,7 @@ RUN apt-get install -y --no-install-recommends \ pkg-config # Needed to install from http endpoints via curl or wget -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ ca-certificates \ libssl-dev \ @@ -28,22 +29,8 @@ RUN apt-get install -y --no-install-recommends \ software-properties-common \ wget -# LLVM Tools -ENV LLVM_VERSION=8 -ADD install_llvm.sh /sledge/install_llvm.sh -RUN ./sledge/install_llvm.sh $LLVM_VERSION - -# Rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --component rustfmt --target wasm32-wasi -y -ENV PATH=/root/.cargo/bin:$PATH -RUN cargo install --debug cargo-audit cargo-watch rsign2 - -# WASI-SDK -RUN curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk_8.0_amd64.deb && dpkg -i wasi-sdk_8.0_amd64.deb && rm -f wasi-sdk_8.0_amd64.deb -ENV WASI_SDK=/opt/wasi-sdk - # Test Script Stuff -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ fonts-dejavu \ fonts-cascadia-code \ fonts-roboto \ @@ -53,11 +40,12 @@ RUN apt-get install -y --no-install-recommends \ wamerican # Hey is a load generator we have to recklessly download from the 'net, as it is only published to brew +# Binaries are only provided for AMD64 though, so ARM will have to build from source # See https://github.com/rakyll/hey -RUN wget https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 && mv hey_linux_amd64 hey && chmod +x hey && mv hey /usr/bin/hey +RUN wget $HEY_URL -O hey && chmod +x hey && mv hey /usr/bin/hey # Interactive Tools -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ bc \ bsdmainutils \ less \ @@ -65,30 +53,58 @@ RUN apt-get install -y --no-install-recommends \ strace \ vim +ENV LLVM_VERSION=8 +ADD install_llvm.sh /sledge/install_llvm.sh +RUN ./sledge/install_llvm.sh $LLVM_VERSION + +# Wasmception +RUN wget $WASMCEPTION_URL -O wasmception.tar.gz +RUN mkdir -p /sledge/awsm/wasmception +RUN tar xvfz wasmception.tar.gz -C /sledge/awsm/wasmception + +# WASI-SDK +# TODO: Refactor to output as an arch-neutral filename +# RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_8.0_amd64.deb && rm -f wasi-sdk_8.0_amd64.deb +# ENV WASI_SDK=/opt/wasi-sdk + +# Create non-root user and add to sudoers +ARG USERNAME=dev +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN groupadd --gid $USER_GID $USERNAME +RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME +RUN apt-get update && apt-get install -y sudo +RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME +RUN chmod 0440 /etc/sudoers.d/$USERNAME + +# Make non-root user default user and use for rest of Dockerfile +USER $USER_UID + +# Make sure the mount point and installation target and any files therein are owned by the non-root user +RUN sudo chown $USER_GID:$USER_GID /sledge +ADD fix_root.sh /sledge/fix_root.sh +RUN cd sledge && ./fix_root.sh +RUN sudo mkdir /opt/sledge +RUN sudo chown $USER_GID:$USER_GID /opt/sledge + +################################ +# Final Setup as non-root user # +################################ + +# Rust +# Rustup does not cleanly support system installs, so install as non-root user +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --component rustfmt --target wasm32-wasi -y +ENV PATH=/home/dev/.cargo/bin:$PATH +RUN cargo install --debug cargo-audit cargo-watch rsign2 + # We need to set the locale for pango-view ENV LANG C.UTF-8 ENV LANGUAGE C.UTF-8 ENV LC_ALL C.UTF-8 +# Update PATH and LD_LIBRARY_PATH ENV PATH=/opt/sledge/bin:$PATH -ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - -# WIP: Try to use a non-root user -# # RUN rm /bin/sh && ln -s /bin/bash /bin/sh - -# ARG USERNAME=dev -# ARG USER_UID=1000 -# ARG USER_GID=$USER_UID - -# # Create the user and add to sudoers -# RUN groupadd --gid $USER_GID $USERNAME -# RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -# RUN apt-get update && apt-get install -y sudo -# RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ -# RUN chmod 0440 /etc/sudoers.d/$USERNAME - -# # ******************************************************** -# # * Anything else you want to do like clean up goes here * -# # ******************************************************** -# # [Optional] Set the default user. Omit if you want to keep the default as root. +# TODO: Does the build process for the sample applications actually copy here? +# TODO: Should we create a special SLEDGE_MODULE_PATH that is searched for these modules? +ENV LD_LIBRARY_PATH=/opt/sledge/bin:LD_LIBRARY_PATH From afa83972060bdc7d399f0a0205e044ffe3b6609f Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 12 Apr 2021 13:44:13 +0000 Subject: [PATCH 10/14] chore: Install clang-format-11 as minimum --- install_llvm.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/install_llvm.sh b/install_llvm.sh index 0a13af5..da1e3c5 100755 --- a/install_llvm.sh +++ b/install_llvm.sh @@ -22,11 +22,18 @@ apt-get install -y --no-install-recommends \ "libc++abi-$LLVM_VERSION-dev" \ "libc++1-$LLVM_VERSION" -# Explicitly use clang-format-11 because of changes between 10 and 11 -apt-get install -y --no-install-recommends \ - "clang-format-11" - update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-$LLVM_VERSION" 100 update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-$LLVM_VERSION" 100 update-alternatives --install /usr/bin/llvm-config llvm-config "/usr/bin/llvm-config-$LLVM_VERSION" 100 -update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-11" 100 +update-alternatives --install /usr/bin/llvm-objdump llvm-objdump "/usr/bin/llvm-objdump-$LLVM_VERSION" 100 + +# Explicitly use at least clang-format-11 to format source because of changes between 10 and 11 +if [[ "$LLVM_VERSION" -ge 11 ]]; then + apt-get install -y --no-install-recommends \ + "clang-format-$LLVM_VERSION" + update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-$LLVM_VERSION" 100 +else + apt-get install -y --no-install-recommends \ + "clang-format-11" + update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-11" 100 +fi From d4002f3cd8384cdaf646d018a22f3f2d86547fd9 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 12 Apr 2021 14:59:21 +0000 Subject: [PATCH 11/14] chore: Add assorted missing tools --- Dockerfile.x86_64 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 index c268ca4..bb4d8fb 100644 --- a/Dockerfile.x86_64 +++ b/Dockerfile.x86_64 @@ -5,6 +5,8 @@ ARG DEBIAN_FRONTEND=noninteractive ARG HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk_8.0_amd64.deb ARG WASMCEPTION_URL=https://github.com/gwsystems/wasmception/releases/download/v0.2.0/wasmception-linux-x86_64-0.2.0.tar.gz +ARG SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.2.4/shfmt_v3.2.4_linux_amd64 +ARG SHELLCHECK_URL=https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz # General GCC C/C++ Build toolchain # pkg-config, libtool - used by PocketSphinx @@ -31,9 +33,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Test Script Stuff RUN apt-get update && apt-get install -y --no-install-recommends \ + bc \ fonts-dejavu \ fonts-cascadia-code \ fonts-roboto \ + gnuplot \ imagemagick \ netpbm \ pango1.0-tools \ @@ -44,14 +48,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # See https://github.com/rakyll/hey RUN wget $HEY_URL -O hey && chmod +x hey && mv hey /usr/bin/hey +# shfmt is a formatter for shell scripts +RUN wget $SHFMT_URL -O shfmt && chmod +x shfmt && mv shfmt /usr/local/bin/shfmt +RUN wget $SHELLCHECK_URL -O shellcheck && chmod +x shellcheck && mv shellcheck /usr/local/bin/shellcheck + # Interactive Tools RUN apt-get update && apt-get install -y --no-install-recommends \ - bc \ bsdmainutils \ - less \ gdb \ + less \ + openssh-client \ strace \ - vim + vim \ + wabt ENV LLVM_VERSION=8 ADD install_llvm.sh /sledge/install_llvm.sh From 0c204001a16c4e4e3c555a1ba00ed62bf1c89b1c Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 12 Apr 2021 14:59:52 +0000 Subject: [PATCH 12/14] chore: Remove extra cmake extensions --- .devcontainer/devcontainer.json | 20 ++++---------------- .vscode/extensions.json | 4 +++- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 67ff064..a490b20 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,24 +21,12 @@ "timonwong.shellcheck", "dtsvet.vscode-wasm", "13xforever.language-x86-64-assembly", - "ms-vscode.cpptools-extension-pack" + "ms-vscode.cpptools", + "ms-vscode.cpptools-themes", + "jeff-hykin.better-cpp-syntax" ], - "workspaceMount": "source=${localWorkspaceFolder},target=/sledge,type=bind,consistency=cached", "workspaceFolder": "/sledge", - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Uncomment the next line to run commands after the container is created - for example installing curl. "postCreateCommand": "make -C /sledge install && make -B -C /sledge/runtime/tests clean all", - - // Uncomment when using a ptrace-based debugger like C++, Go, and Rust - // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], - - // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. - // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], - - // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "root", + "containerUser": "dev", } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index a78a207..dd5cc50 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,6 +5,8 @@ "timonwong.shellcheck", "dtsvet.vscode-wasm", "13xforever.language-x86-64-assembly", - "ms-vscode.cpptools-extension-pack" + "ms-vscode.cpptools", + "ms-vscode.cpptools-themes", + "jeff-hykin.better-cpp-syntax" ] } From 16153b997c1d7ec64ee488a0e7c4519146337815 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 12 Apr 2021 15:00:23 +0000 Subject: [PATCH 13/14] chore: Use bash interactively --- .vscode/settings.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 45fd335..8fd085a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -71,5 +71,11 @@ "**/.vscode": true }, - "shellformat.flag": "-ln=bash -i 0 -bn -ci -sr -kp" + "shellformat.flag": "-ln=bash -i 0 -bn -ci -sr -kp", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash" + } + }, + "terminal.integrated.shell.linux": "bash" } From 14a96de7761dd801ab5fde06800f3facda93f4f1 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 12 Apr 2021 16:19:45 +0000 Subject: [PATCH 14/14] chore: bash cleanup --- .../applications/imageclassification/run.sh | 2 +- .../applications/ocr/by_dpi/run.sh | 2 +- .../applications/ocr/by_font/run.sh | 30 ++++++------- runtime/experiments/applications/run.sh | 32 +++++++------- runtime/experiments/common.sh | 18 ++++++++ runtime/experiments/concurrency/run.sh | 32 +++++++------- runtime/experiments/deadline/client.sh | 35 +++++++-------- runtime/experiments/deadline/client2.sh | 31 +++++++------ runtime/experiments/deadline/client3.sh | 31 +++++++------ runtime/experiments/deadline/fix_calcs.sh | 28 ++++++------ runtime/experiments/deadline/fix_calcs2.sh | 30 ++++++------- runtime/experiments/deadline/run.sh | 32 +++++++------- runtime/experiments/deadline/run_relative.sh | 32 +++++++------- runtime/experiments/deadline/server.sh | 2 - runtime/experiments/payload/run.sh | 34 +++++++------- runtime/experiments/preemption/client.sh | 32 +++++++------- runtime/experiments/preemption/fix_results.sh | 40 ++++++++--------- runtime/experiments/preemption/run.sh | 44 ++++++++++++------- .../experiments/preemption/run_relative.sh | 32 +++++++------- 19 files changed, 271 insertions(+), 248 deletions(-) diff --git a/runtime/experiments/applications/imageclassification/run.sh b/runtime/experiments/applications/imageclassification/run.sh index 4c095cb..4218303 100755 --- a/runtime/experiments/applications/imageclassification/run.sh +++ b/runtime/experiments/applications/imageclassification/run.sh @@ -21,7 +21,7 @@ else echo "Running under gdb" fi -# expected_size="$(find expected_result.jpg -printf "%s")" +expected_size="$(find expected_result.jpg -printf "%s")" success_count=0 total_count=50 diff --git a/runtime/experiments/applications/ocr/by_dpi/run.sh b/runtime/experiments/applications/ocr/by_dpi/run.sh index 0d25b80..72df78d 100755 --- a/runtime/experiments/applications/ocr/by_dpi/run.sh +++ b/runtime/experiments/applications/ocr/by_dpi/run.sh @@ -33,7 +33,7 @@ for ((i = 0; i < total_count; i++)); do for dpi in "${dpis[@]}"; do echo "${dpi}"_dpi.pnm - pango-view --dpi=$dpi --font=mono -qo "${dpi}"_dpi.png -t "$words" + pango-view --dpi="$dpi" --font=mono -qo "${dpi}"_dpi.png -t "$words" pngtopnm "${dpi}"_dpi.png > "${dpi}"_dpi.pnm result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @"${dpi}"_dpi.pnm localhost:${dpi_to_port[$dpi]} 2> /dev/null) diff --git a/runtime/experiments/applications/ocr/by_font/run.sh b/runtime/experiments/applications/ocr/by_font/run.sh index 83acad0..ca2f8be 100755 --- a/runtime/experiments/applications/ocr/by_font/run.sh +++ b/runtime/experiments/applications/ocr/by_font/run.sh @@ -29,25 +29,25 @@ for ((i = 1; i <= total_count; i++)); do # For whatever reason, templating in multiple word strips was a pain, so brute forcing case "$font" in "DejaVu Sans Mono") - echo "DejaVu Sans Mono" - pango-view --font="DejaVu Sans Mono" -qo mono_words.png -t "$words" || exit 1 - pngtopnm mono_words.png > mono_words.pnm || exit 1 - result=$( curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @mono_words.pnm localhost:10000 2> /dev/null) - diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result") + echo "DejaVu Sans Mono" + pango-view --font="DejaVu Sans Mono" -qo mono_words.png -t "$words" || exit 1 + pngtopnm mono_words.png > mono_words.pnm || exit 1 + result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @mono_words.pnm localhost:10000 2> /dev/null) + diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result") ;; "Roboto") - echo "Roboto" - pango-view --font="Roboto" -qo Roboto_words.png -t "$words" || exit 1 - pngtopnm Roboto_words.png > Roboto_words.pnm || exit 1 - result=$( curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @Roboto_words.pnm localhost:10002 2> /dev/null) - diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result") + echo "Roboto" + pango-view --font="Roboto" -qo Roboto_words.png -t "$words" || exit 1 + pngtopnm Roboto_words.png > Roboto_words.pnm || exit 1 + result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @Roboto_words.pnm localhost:10002 2> /dev/null) + diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result") ;; "Cascadia Code") - echo "Cascadia Code" - pango-view --font="Cascadia Code" -qo Cascadia_Code_words.png -t "$words" || exit 1 - pngtopnm Cascadia_Code_words.png > Cascadia_Code_words.pnm || exit 1 - result=$( curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @Cascadia_Code_words.pnm localhost:10001 2> /dev/null) - diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result") + echo "Cascadia Code" + pango-view --font="Cascadia Code" -qo Cascadia_Code_words.png -t "$words" || exit 1 + pngtopnm Cascadia_Code_words.png > Cascadia_Code_words.pnm || exit 1 + result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @Cascadia_Code_words.pnm localhost:10001 2> /dev/null) + diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result") ;; esac echo "===============================================" diff --git a/runtime/experiments/applications/run.sh b/runtime/experiments/applications/run.sh index 6070bcd..04843d1 100755 --- a/runtime/experiments/applications/run.sh +++ b/runtime/experiments/applications/run.sh @@ -61,9 +61,9 @@ for payload in ${payloads[*]}; do # Calculate Success Rate for csv file=$(echo "$payload" | awk -F/ '{print $2}') awk -F, ' - $7 == 200 {ok++} - END{printf "'"$file"',%3.5f\n", (ok / '"$iterations"' * 100)} - ' < "$results_directory/$file.csv" >> "$results_directory/success.csv" + $7 == 200 {ok++} + END{printf "'"$file"',%3.5f\n", (ok / '"$iterations"' * 100)} + ' < "$results_directory/$file.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$file.csv" \ @@ -80,19 +80,19 @@ for payload in ${payloads[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$file"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} - ' < "$results_directory/$file-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$file"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/$file-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting rm -rf "$results_directory/$file-response.csv" diff --git a/runtime/experiments/common.sh b/runtime/experiments/common.sh index 28a932e..bbfe879 100644 --- a/runtime/experiments/common.sh +++ b/runtime/experiments/common.sh @@ -1,6 +1,10 @@ #!/bin/bash log_environment() { + if ! command -v git &> /dev/null; then + echo "git could not be found" + exit + fi echo "*******" echo "* Git *" echo "*******" @@ -39,6 +43,20 @@ kill_runtime() { } generate_gnuplots() { + if ! command -v gnuplot &> /dev/null; then + echo "gnuplot could not be found" + exit + fi + # shellcheck disable=SC2154 + if [ -z "$results_directory" ]; then + echo "results_directory is unset or empty" + exit + fi + # shellcheck disable=SC2154 + if [ -z "$experiment_directory" ]; then + echo "experiment_directory is unset or empty" + exit + fi cd "$results_directory" || exit gnuplot ../../latency.gnuplot gnuplot ../../success.gnuplot diff --git a/runtime/experiments/concurrency/run.sh b/runtime/experiments/concurrency/run.sh index c651c47..47bcb9e 100755 --- a/runtime/experiments/concurrency/run.sh +++ b/runtime/experiments/concurrency/run.sh @@ -57,9 +57,9 @@ printf "Con,p50,p90,p99,p100\n" >> "$results_directory/latency.csv" for conn in ${concurrency[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {ok++} - END{printf "'"$conn"',%3.5f\n", (ok / '"$iterations"' * 100)} - ' < "$results_directory/con$conn.csv" >> "$results_directory/success.csv" + $7 == 200 {ok++} + END{printf "'"$conn"',%3.5f\n", (ok / '"$iterations"' * 100)} + ' < "$results_directory/con$conn.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/con$conn.csv" \ @@ -76,19 +76,19 @@ for conn in ${concurrency[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$conn"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} - ' < "$results_directory/con$conn-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$conn"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/con$conn-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting rm -rf "$results_directory/con$conn-response.csv" diff --git a/runtime/experiments/deadline/client.sh b/runtime/experiments/deadline/client.sh index 4063a83..d1acfb1 100755 --- a/runtime/experiments/deadline/client.sh +++ b/runtime/experiments/deadline/client.sh @@ -7,7 +7,6 @@ source ../common.sh host=localhost timestamp=$(date +%s) experiment_directory=$(pwd) -binary_directory=$(cd ../../bin && pwd) results_directory="$experiment_directory/res/$timestamp" log=log.txt @@ -31,9 +30,9 @@ echo "Running Experiments" # Run lower priority first, then higher priority. The lower priority has offsets to ensure it runs the entire time the high priority is trying to run hey -n 1000 -c 1000 -cpus 6 -t 0 -o csv -m GET -d "40\n" http://${host}:10040 > "$results_directory/fib40-con.csv" -# sleep $offset -# hey -n 25000 -c 1000000 -t 0 -o csv -m GET -d "10\n" http://${host}:10010 >"$results_directory/fib10-con.csv" & -# sleep $((duration_sec + offset + 45)) +sleep $offset +hey -n 25000 -c 1000000 -t 0 -o csv -m GET -d "10\n" http://${host}:10010 > "$results_directory/fib10-con.csv" & +sleep $((duration_sec + offset + 45)) # Generate *.csv and *.dat results echo -n "Parsing Results: " @@ -57,8 +56,8 @@ for ((i = 1; i < 2; i++)); do # Calculate Success Rate for csv awk -F, ' - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort @@ -75,18 +74,18 @@ for ((i = 1; i < 2; i++)); do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting diff --git a/runtime/experiments/deadline/client2.sh b/runtime/experiments/deadline/client2.sh index 17990e8..2d9ca11 100755 --- a/runtime/experiments/deadline/client2.sh +++ b/runtime/experiments/deadline/client2.sh @@ -8,7 +8,6 @@ host=192.168.1.13 # host=localhost timestamp=$(date +%s) experiment_directory=$(pwd) -binary_directory=$(cd ../../bin && pwd) results_directory="$experiment_directory/res/$timestamp" log=log.txt @@ -59,9 +58,9 @@ for ((i = 0; i < 2; i++)); do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {denom++} - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / denom * 100)} + $7 == 200 {denom++} + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / denom * 100)} ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort @@ -79,18 +78,18 @@ for ((i = 0; i < 2; i++)); do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting diff --git a/runtime/experiments/deadline/client3.sh b/runtime/experiments/deadline/client3.sh index 8d203c7..10e186c 100755 --- a/runtime/experiments/deadline/client3.sh +++ b/runtime/experiments/deadline/client3.sh @@ -8,7 +8,6 @@ host=192.168.1.13 # host=localhost timestamp=$(date +%s) experiment_directory=$(pwd) -binary_directory=$(cd ../../bin && pwd) results_directory="$experiment_directory/res/$timestamp" log=log.txt @@ -57,9 +56,9 @@ for ((i = 0; i < 1; i++)); do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {denom++} - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / denom * 100)} + $7 == 200 {denom++} + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / denom * 100)} ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort @@ -77,18 +76,18 @@ for ((i = 0; i < 1; i++)); do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting diff --git a/runtime/experiments/deadline/fix_calcs.sh b/runtime/experiments/deadline/fix_calcs.sh index 057a19f..7d8d5eb 100755 --- a/runtime/experiments/deadline/fix_calcs.sh +++ b/runtime/experiments/deadline/fix_calcs.sh @@ -27,8 +27,8 @@ for ((i = 0; i < 2; i++)); do # Calculate Success Rate for csv awk -F, ' - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort @@ -46,18 +46,18 @@ for ((i = 0; i < 2; i++)); do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting diff --git a/runtime/experiments/deadline/fix_calcs2.sh b/runtime/experiments/deadline/fix_calcs2.sh index 5a1ec6e..adff3c2 100755 --- a/runtime/experiments/deadline/fix_calcs2.sh +++ b/runtime/experiments/deadline/fix_calcs2.sh @@ -60,9 +60,9 @@ for ((i = 0; i < 2; i++)); do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {denom++} - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / denom * 100)} + $7 == 200 {denom++} + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / denom * 100)} ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort @@ -80,18 +80,18 @@ for ((i = 0; i < 2; i++)); do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting diff --git a/runtime/experiments/deadline/run.sh b/runtime/experiments/deadline/run.sh index 0847d4f..c69a3e5 100755 --- a/runtime/experiments/deadline/run.sh +++ b/runtime/experiments/deadline/run.sh @@ -73,9 +73,9 @@ for scheduler in ${schedulers[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} - ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -92,19 +92,19 @@ for scheduler in ${schedulers[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} - ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting # rm -rf "$results_directory/$payload-response.csv" diff --git a/runtime/experiments/deadline/run_relative.sh b/runtime/experiments/deadline/run_relative.sh index 31d6c2a..0acc690 100755 --- a/runtime/experiments/deadline/run_relative.sh +++ b/runtime/experiments/deadline/run_relative.sh @@ -73,9 +73,9 @@ for scheduler in ${schedulers[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} - ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -92,19 +92,19 @@ for scheduler in ${schedulers[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f%,", $0 / '"$deadline"' * 100} - NR==p90 {printf "%1.4f%,", $0 / '"$deadline"' * 100} - NR==p99 {printf "%1.4f%,", $0 / '"$deadline"' * 100} - NR==p100 {printf "%1.4f%\n", $0 / '"$deadline"' * 100} - ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f%,", $0 / '"$deadline"' * 100} + NR==p90 {printf "%1.4f%,", $0 / '"$deadline"' * 100} + NR==p99 {printf "%1.4f%,", $0 / '"$deadline"' * 100} + NR==p100 {printf "%1.4f%\n", $0 / '"$deadline"' * 100} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting # rm -rf "$results_directory/$payload-response.csv" diff --git a/runtime/experiments/deadline/server.sh b/runtime/experiments/deadline/server.sh index e1e2e5b..965228e 100755 --- a/runtime/experiments/deadline/server.sh +++ b/runtime/experiments/deadline/server.sh @@ -1,7 +1,5 @@ #!/bin/bash -source ../common.sh -timestamp=$(date +%s) experiment_directory=$(pwd) binary_directory=$(cd ../../bin && pwd) diff --git a/runtime/experiments/payload/run.sh b/runtime/experiments/payload/run.sh index 718c57e..7731a81 100755 --- a/runtime/experiments/payload/run.sh +++ b/runtime/experiments/payload/run.sh @@ -34,7 +34,7 @@ for payload in ${payloads[*]}; do else echo "Generating Payloads: " { - cd "$experiment_directory/body" && ./generate.sh + cd "$experiment_directory/body" && ./generate.sh } break fi @@ -73,9 +73,9 @@ printf "Payload,p50,p90,p99,p100\n" >> "$results_directory/latency.csv" for payload in ${payloads[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {ok++} - END{printf "'"$payload"',%3.5f\n", (ok / '"$iterations"' * 100)} - ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 {ok++} + END{printf "'"$payload"',%3.5f\n", (ok / '"$iterations"' * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -92,19 +92,19 @@ for payload in ${payloads[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} - ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting rm -rf "$results_directory/$payload-response.csv" diff --git a/runtime/experiments/preemption/client.sh b/runtime/experiments/preemption/client.sh index ad07df3..e0b7584 100755 --- a/runtime/experiments/preemption/client.sh +++ b/runtime/experiments/preemption/client.sh @@ -61,9 +61,9 @@ for payload in ${payloads[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} -' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -80,19 +80,19 @@ for payload in ${payloads[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} -' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting # rm -rf "$results_directory/$payload-response.csv" diff --git a/runtime/experiments/preemption/fix_results.sh b/runtime/experiments/preemption/fix_results.sh index 3a527bd..80c6b1f 100755 --- a/runtime/experiments/preemption/fix_results.sh +++ b/runtime/experiments/preemption/fix_results.sh @@ -27,9 +27,9 @@ for payload in ${payloads[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} -' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -46,23 +46,23 @@ for payload in ${payloads[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p998 = int('"$oks"' * 0.998) - p999 = int('"$oks"' * 0.999) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p998 {printf "%1.4f,", $0} - NR==p999 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} -' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p998 = int('"$oks"' * 0.998) + p999 = int('"$oks"' * 0.999) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p998 {printf "%1.4f,", $0} + NR==p999 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting # rm -rf "$results_directory/$payload-response.csv" diff --git a/runtime/experiments/preemption/run.sh b/runtime/experiments/preemption/run.sh index 0847d4f..b549e21 100755 --- a/runtime/experiments/preemption/run.sh +++ b/runtime/experiments/preemption/run.sh @@ -1,9 +1,19 @@ #!/bin/bash -source ../common.sh # This experiment is intended to document how the level of concurrent requests influence the latency, throughput, and success/failure rate # Use -d flag if running under gdb +source ../common.sh + +# Validate dependencies +declare -a -r dependencies=(awk hey wc) +for dependency in "${dependencies[@]}"; do + if ! command -v "$dependency" &> /dev/null; then + echo "$dependency could not be found" + exit + fi +done + timestamp=$(date +%s) experiment_directory=$(pwd) binary_directory=$(cd ../../bin && pwd) @@ -73,9 +83,9 @@ for scheduler in ${schedulers[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} - ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f\n", (ok / (NR - 1) * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -92,19 +102,19 @@ for scheduler in ${schedulers[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f,", $0} - NR==p90 {printf "%1.4f,", $0} - NR==p99 {printf "%1.4f,", $0} - NR==p100 {printf "%1.4f\n", $0} - ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f,", $0} + NR==p90 {printf "%1.4f,", $0} + NR==p99 {printf "%1.4f,", $0} + NR==p100 {printf "%1.4f\n", $0} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting # rm -rf "$results_directory/$payload-response.csv" diff --git a/runtime/experiments/preemption/run_relative.sh b/runtime/experiments/preemption/run_relative.sh index 31d6c2a..0acc690 100755 --- a/runtime/experiments/preemption/run_relative.sh +++ b/runtime/experiments/preemption/run_relative.sh @@ -73,9 +73,9 @@ for scheduler in ${schedulers[*]}; do # Calculate Success Rate for csv awk -F, ' - $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} - END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} - ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" + $7 == 200 && ($1 * 1000) <= '"$deadline"' {ok++} + END{printf "'"$payload"',%3.5f%\n", (ok / (NR - 1) * 100)} + ' < "$results_directory/$payload.csv" >> "$results_directory/success.csv" # Filter on 200s, convery from s to ms, and sort awk -F, '$7 == 200 {print ($1 * 1000)}' < "$results_directory/$payload.csv" \ @@ -92,19 +92,19 @@ for scheduler in ${schedulers[*]}; do # Generate Latency Data for csv awk ' - BEGIN { - sum = 0 - p50 = int('"$oks"' * 0.5) - p90 = int('"$oks"' * 0.9) - p99 = int('"$oks"' * 0.99) - p100 = '"$oks"' - printf "'"$payload"'," - } - NR==p50 {printf "%1.4f%,", $0 / '"$deadline"' * 100} - NR==p90 {printf "%1.4f%,", $0 / '"$deadline"' * 100} - NR==p99 {printf "%1.4f%,", $0 / '"$deadline"' * 100} - NR==p100 {printf "%1.4f%\n", $0 / '"$deadline"' * 100} - ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" + BEGIN { + sum = 0 + p50 = int('"$oks"' * 0.5) + p90 = int('"$oks"' * 0.9) + p99 = int('"$oks"' * 0.99) + p100 = '"$oks"' + printf "'"$payload"'," + } + NR==p50 {printf "%1.4f%,", $0 / '"$deadline"' * 100} + NR==p90 {printf "%1.4f%,", $0 / '"$deadline"' * 100} + NR==p99 {printf "%1.4f%,", $0 / '"$deadline"' * 100} + NR==p100 {printf "%1.4f%\n", $0 / '"$deadline"' * 100} + ' < "$results_directory/$payload-response.csv" >> "$results_directory/latency.csv" # Delete scratch file used for sorting/counting # rm -rf "$results_directory/$payload-response.csv"