From 249ab17214c6152b110ecaf93fa2e11f3998f3b9 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Wed, 23 Feb 2022 14:52:11 -0500 Subject: [PATCH] chore: wasmception cleanup --- .vscode/settings.json | 4 +++- awsm | 2 +- driver.sh | 32 ++++++++++++++++++++++++++ libsledge/Makefile | 13 ++++++----- runtime/Makefile | 6 ++--- runtime/include/sandbox_perf_log.h | 2 +- runtime/src/libc/syscall.c | 10 ++++---- tests/workload_mix/run.sh | 2 +- tests/workload_mix_realworld/Makefile | 14 +++++++++++ tests/workload_mix_realworld/run.sh | 5 ++-- tests/workload_mix_realworld/spec.json | 24 +++++++++---------- wasm32-unknown-unknown-wasm-clang | 3 +++ 12 files changed, 85 insertions(+), 32 deletions(-) create mode 100755 driver.sh create mode 100644 tests/workload_mix_realworld/Makefile create mode 100755 wasm32-unknown-unknown-wasm-clang diff --git a/.vscode/settings.json b/.vscode/settings.json index d57a189c..25ce102c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -104,7 +104,9 @@ "wasm_module_instance.h": "c", "wasm_stack.h": "c", "wasm_table.h": "c", - "sledge_abi.h": "c" + "sledge_abi.h": "c", + "__bit_reference": "cpp", + "filesystem": "cpp" }, "files.exclude": { "**/.git": true, diff --git a/awsm b/awsm index 90b535a6..3aca5263 160000 --- a/awsm +++ b/awsm @@ -1 +1 @@ -Subproject commit 90b535a67ca09421e55b74de06f4a8a817131a8c +Subproject commit 3aca5263d346065173d35437c319d6d3d61204b9 diff --git a/driver.sh b/driver.sh new file mode 100755 index 00000000..7a503758 --- /dev/null +++ b/driver.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# git checkout wasmception +# git submodule update --recursive +# make libsledge +# make build +# make -C runtime clean all +# rm runtime/bin/*.so +cd awsm +cargo build --release +cd .. + +touch wasm32-unknown-unknown-wasm-clang +wrapper_file=wasm32-unknown-unknown-wasm-clang + +cat > "$wrapper_file" << EOT +#!/bin/sh + +exec /home/sean/projects/sledge/awsm/wasmception/dist/bin/clang --target=wasm32-unknown-unknown-wasm --sysroot=/home/sean/projects/sledge/awsm/wasmception/sysroot "\$@" +EOT + +chmod +x wasm32-unknown-unknown-wasm-clang +sudo install wasm32-unknown-unknown-wasm-clang /usr/bin + +sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 1000 +sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-8 1000 + +make -C applications clean all + +make -f test.mk all + +cd ./tests/gocr/by_dpi && SLEDGE_NWORKERS=1 ./run.sh -e=fifo_nopreemption.env diff --git a/libsledge/Makefile b/libsledge/Makefile index ad380391..611ea80b 100644 --- a/libsledge/Makefile +++ b/libsledge/Makefile @@ -1,7 +1,8 @@ CFILES := src/*.c INCLUDES := -Iinclude/ -CFLAGS := -fPIC -O3 +# CFLAGS := -fPIC -O3 +CFLAGS := -fPIC -O0 -g # CFI Sanitizer # CFLAGS+=-fvisibility=default -fsanitize=cfi @@ -24,19 +25,19 @@ dist: mkdir dist dist/memory_instructions.o: src/memory_instructions.c dist - clang ${CFLAGS} -c ${INCLUDES} -o $@ $< + clang-8 ${CFLAGS} -c ${INCLUDES} -o $@ $< dist/numeric_instructions.o: src/numeric_instructions.c dist - clang ${CFLAGS} -c ${INCLUDES} -o $@ $< + clang-8 ${CFLAGS} -c ${INCLUDES} -o $@ $< dist/table_instructions.o: src/table_instructions.c dist - clang ${CFLAGS} -c ${INCLUDES} -o $@ $< + clang-8 ${CFLAGS} -c ${INCLUDES} -o $@ $< dist/variable_instructions.o: src/variable_instructions.c dist - clang ${CFLAGS} -c ${INCLUDES} -o $@ $< + clang-8 ${CFLAGS} -c ${INCLUDES} -o $@ $< dist/instantiation.o: src/instantiation.c dist - clang ${CFLAGS} -c ${INCLUDES} -o $@ $< + clang-8 ${CFLAGS} -c ${INCLUDES} -o $@ $< dist/libsledge.a: dist/memory_instructions.o dist/numeric_instructions.o dist/table_instructions.o dist/variable_instructions.o dist/instantiation.o ar rcs dist/libsledge.a $^ diff --git a/runtime/Makefile b/runtime/Makefile index 2cd1f7a4..c616f7e8 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -6,7 +6,7 @@ endif endif # Compiler Settings -CC=clang +CC=clang-8 CFLAGS=-std=c18 -pthread # We use several non-standard glibc / Linux features: @@ -14,10 +14,10 @@ CFLAGS=-std=c18 -pthread CFLAGS+=-D_GNU_SOURCE # Release Flags -CFLAGS+=-O3 -flto +# CFLAGS+=-O3 -flto # Debugging Flags -# CFLAGS+=-O0 -g +CFLAGS+=-O0 -g # CFI Sanitizer # CFLAGS+=-fvisibility=default -fsanitize=cfi diff --git a/runtime/include/sandbox_perf_log.h b/runtime/include/sandbox_perf_log.h index 026a1384..cd19255c 100644 --- a/runtime/include/sandbox_perf_log.h +++ b/runtime/include/sandbox_perf_log.h @@ -45,7 +45,7 @@ sandbox_perf_log_print_entry(struct sandbox *sandbox) sandbox->duration_of_state[SANDBOX_RUNNING_SYS], sandbox->duration_of_state[SANDBOX_RUNNING_USER], sandbox->duration_of_state[SANDBOX_ASLEEP], sandbox->duration_of_state[SANDBOX_RETURNED], sandbox->duration_of_state[SANDBOX_COMPLETE], sandbox->duration_of_state[SANDBOX_ERROR], - runtime_processor_speed_MHz, sandbox->memory->abi.size); + runtime_processor_speed_MHz, 0); } static inline void diff --git a/runtime/src/libc/syscall.c b/runtime/src/libc/syscall.c index 52ea0a8f..6101f37b 100644 --- a/runtime/src/libc/syscall.c +++ b/runtime/src/libc/syscall.c @@ -95,7 +95,7 @@ wasm_read(int32_t filedes, int32_t buf_offset, int32_t nbyte) /* Non-blocking copy on stdin */ if (filedes == 0) { - char * buffer = current_sandbox_get_ptr_void(buf_offset, nbyte); + char *buffer = current_sandbox_get_ptr_void(buf_offset, nbyte); struct http_request *current_request = ¤t_sandbox->http_request; if (current_request->body_length <= 0) return 0; int bytes_to_read = nbyte > current_request->body_length ? current_request->body_length : nbyte; @@ -136,8 +136,8 @@ int32_t wasm_write(int32_t fd, int32_t buf_offset, int32_t buf_size) { struct sandbox *s = current_sandbox_get(); - char * buffer = current_sandbox_get_ptr_void(buf_offset, buf_size); - struct vec_u8 * response = &s->response; + char *buffer = current_sandbox_get_ptr_void(buf_offset, buf_size); + struct vec_u8 *response = &s->response; if (fd == STDERR_FILENO) { write(STDERR_FILENO, buffer, buf_size); } @@ -291,7 +291,7 @@ wasm_writev(int32_t fd, int32_t iov_offset, int32_t iovcnt) int sum = 0; for (int i = 0; i < iovcnt; i++) { int32_t len = iov[i].len; - void * ptr = current_sandbox_get_ptr_void(iov[i].base_offset, len); + void *ptr = current_sandbox_get_ptr_void(iov[i].base_offset, len); printf("%.*s", len, (char *)ptr); sum += len; @@ -303,7 +303,7 @@ wasm_writev(int32_t fd, int32_t iov_offset, int32_t iovcnt) struct iovec vecs[iovcnt]; for (int i = 0; i < iovcnt; i++) { int32_t len = iov[i].len; - void * ptr = current_sandbox_get_ptr_void(iov[i].base_offset, len); + void *ptr = current_sandbox_get_ptr_void(iov[i].base_offset, len); vecs[i] = (struct iovec){ ptr, len }; } diff --git a/tests/workload_mix/run.sh b/tests/workload_mix/run.sh index 7b616a55..1a925290 100755 --- a/tests/workload_mix/run.sh +++ b/tests/workload_mix/run.sh @@ -37,7 +37,7 @@ run_samples() { # Scrape the perf window size from the source if possible # TODO: Make a util function - local -r perf_window_path="$(path_join "$__run_sh__base_path" ../../include/perf_window_t.h)" + local -r perf_window_path="$(path_join "$__run_sh__base_path" ../../runtime/include/perf_window_t.h)" local -i perf_window_buffer_size if ! perf_window_buffer_size=$(grep "#define PERF_WINDOW_BUFFER_SIZE" < "$perf_window_path" | cut -d\ -f3); then printf "Failed to scrape PERF_WINDOW_BUFFER_SIZE from ../../include/perf_window.h\n" diff --git a/tests/workload_mix_realworld/Makefile b/tests/workload_mix_realworld/Makefile new file mode 100644 index 00000000..879fccae --- /dev/null +++ b/tests/workload_mix_realworld/Makefile @@ -0,0 +1,14 @@ +client-cifar10: + cat ./cifar10/airplane1.bmp | http :10019 + +client-ekf: + cat ./ekf/ekf_raw.dat | http :10000 + +client-gocr: + cat ./gocr/hyde.pnm | http :10006 + +client-lpd: + cat ./lpd/Cars0.png | http :10012 + +client-resize: + cat ./resize/shrinking_man_large.jpg | http :10018 diff --git a/tests/workload_mix_realworld/run.sh b/tests/workload_mix_realworld/run.sh index f06a46a8..7a6521a2 100755 --- a/tests/workload_mix_realworld/run.sh +++ b/tests/workload_mix_realworld/run.sh @@ -44,6 +44,7 @@ initialize_globals() { # Read into buffer array, splitting on commas readarray -t -d, buffer < <(echo -n "$line") workload="${buffer[1]}" + echo "$workload" # Update workload mix structures workloads+=("$workload") port+=(["$workload"]=$(get_port "$workload")) @@ -53,9 +54,9 @@ initialize_globals() { get_port() { local name="$1" { - echo "[" + # echo "[" cat ./spec.json - echo "]" + # echo "]" } | jq ".[] | select(.name == \"$name\") | .port" } diff --git a/tests/workload_mix_realworld/spec.json b/tests/workload_mix_realworld/spec.json index f69aa0dd..5eb667fa 100644 --- a/tests/workload_mix_realworld/spec.json +++ b/tests/workload_mix_realworld/spec.json @@ -5,8 +5,8 @@ "port": 10018, "expected-execution-us": 2777, "relative-deadline-us": 4166, - "http-req-size": 4096, - "http-resp-size": 128, + "http-req-size": 1024000, + "http-resp-size": 1024000, "http-resp-content-type": "text/plain", "admissions-percentile": 90 }, @@ -16,8 +16,8 @@ "port": 10019, "expected-execution-us": 2777, "relative-deadline-us": 4443, - "http-req-size": 4096, - "http-resp-size": 128, + "http-req-size": 1024000, + "http-resp-size": 1024000, "http-resp-content-type": "text/plain", "admissions-percentile": 90 }, @@ -27,8 +27,8 @@ "port": 10020, "expected-execution-us": 2777, "relative-deadline-us": 4721, - "http-req-size": 4096, - "http-resp-size": 128, + "http-req-size": 1024000, + "http-resp-size": 1024000, "http-resp-content-type": "text/plain", "admissions-percentile": 90 }, @@ -38,8 +38,8 @@ "port": 10021, "expected-execution-us": 2777, "relative-deadline-us": 4999, - "http-req-size": 4096, - "http-resp-size": 128, + "http-req-size": 1024000, + "http-resp-size": 1024000, "http-resp-content-type": "text/plain", "admissions-percentile": 90 }, @@ -49,8 +49,8 @@ "port": 10022, "expected-execution-us": 2777, "relative-deadline-us": 5276, - "http-req-size": 4096, - "http-resp-size": 128, + "http-req-size": 1024000, + "http-resp-size": 1024000, "http-resp-content-type": "text/plain", "admissions-percentile": 90 }, @@ -60,8 +60,8 @@ "port": 10023, "expected-execution-us": 2777, "relative-deadline-us": 5554, - "http-req-size": 4096, - "http-resp-size": 128, + "http-req-size": 1024000, + "http-resp-size": 1024000, "http-resp-content-type": "text/plain", "admissions-percentile": 90 }, diff --git a/wasm32-unknown-unknown-wasm-clang b/wasm32-unknown-unknown-wasm-clang new file mode 100755 index 00000000..031af605 --- /dev/null +++ b/wasm32-unknown-unknown-wasm-clang @@ -0,0 +1,3 @@ +#!/bin/sh + +exec /home/sean/projects/sledge/awsm/wasmception/dist/bin/clang --target=wasm32-unknown-unknown-wasm --sysroot=/home/sean/projects/sledge/awsm/wasmception/sysroot "$@"