From 135ba6105fc7d93c522d183f2f8cf5afab822bac Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 5 Apr 2022 12:00:14 -0400 Subject: [PATCH] chore: update wasm apps --- .vscode/settings.json | 1 + applications/Makefile | 3 ++ applications/wasm_apps | 2 +- libsledge/src/wasi_snapshot_preview1.c | 2 +- runtime/include/current_sandbox.h | 2 + runtime/include/http.h | 2 +- runtime/include/sandbox_receive_request.h | 2 +- runtime/src/current_sandbox.c | 2 +- runtime/src/http_parser_settings.c | 1 - runtime/src/libc/wasi_impl_serverless.c | 5 +-- runtime/src/sledge_abi.c | 3 +- tests/html/.gitignore | 3 ++ tests/html/Makefile | 47 +++++++++++++++++++++++ tests/html/edf_nopreemption.env | 2 + tests/html/edf_preemption.env | 3 ++ tests/html/fifo_nopreemption.env | 2 + tests/html/fifo_preemption.env | 2 + tests/html/install.sh | 13 +++++++ tests/html/spec.json | 13 +++++++ 19 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 tests/html/.gitignore create mode 100644 tests/html/Makefile create mode 100644 tests/html/edf_nopreemption.env create mode 100644 tests/html/edf_preemption.env create mode 100644 tests/html/fifo_nopreemption.env create mode 100644 tests/html/fifo_preemption.env create mode 100755 tests/html/install.sh create mode 100644 tests/html/spec.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 5710bac..f8a6af4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -110,6 +110,7 @@ "current_wasm_module_instance.h": "c", "wasm_memory.h": "c", "sledge_abi.h": "c", + "vec.h": "c" }, "files.exclude": { "**/.git": true, diff --git a/applications/Makefile b/applications/Makefile index 3b0a525..a461aa2 100644 --- a/applications/Makefile +++ b/applications/Makefile @@ -85,3 +85,6 @@ trap_divzero.install: ../runtime/bin/trap_divzero.wasm.so .PHONY: stack_overflow.install stack_overflow.install: ../runtime/bin/stack_overflow.wasm.so + +.PHONY: html.install +html.install: ../runtime/bin/html.wasm.so diff --git a/applications/wasm_apps b/applications/wasm_apps index a52b7f2..d1c345f 160000 --- a/applications/wasm_apps +++ b/applications/wasm_apps @@ -1 +1 @@ -Subproject commit a52b7f278b751f7a0ecc146edb4585fd702534f6 +Subproject commit d1c345ffacf11a9478ee5ec0772fe5104bc752f5 diff --git a/libsledge/src/wasi_snapshot_preview1.c b/libsledge/src/wasi_snapshot_preview1.c index 130db86..edf7172 100644 --- a/libsledge/src/wasi_snapshot_preview1.c +++ b/libsledge/src/wasi_snapshot_preview1.c @@ -268,7 +268,7 @@ wasi_snapshot_preview1_poll_oneoff(__wasi_size_t in_baseoffset, __wasi_size_t ou void wasi_snapshot_preview1_proc_exit(__wasi_exitcode_t exitcode) { - sledge_abi__wasi_snapshot_preview1_proc_raise(exitcode); + sledge_abi__wasi_snapshot_preview1_proc_exit(exitcode); } uint32_t diff --git a/runtime/include/current_sandbox.h b/runtime/include/current_sandbox.h index df31aac..fa84dff 100644 --- a/runtime/include/current_sandbox.h +++ b/runtime/include/current_sandbox.h @@ -109,3 +109,5 @@ current_sandbox_trap(enum sledge_abi__wasm_trap trapno) siglongjmp(sandbox->ctxt.start_buf, trapno); } + +extern noreturn void current_sandbox_fini(); diff --git a/runtime/include/http.h b/runtime/include/http.h index fc05dec..0fe2dcc 100644 --- a/runtime/include/http.h +++ b/runtime/include/http.h @@ -7,7 +7,7 @@ #define HTTP_MAX_HEADER_COUNT 16 #define HTTP_MAX_HEADER_LENGTH 32 -#define HTTP_MAX_HEADER_VALUE_LENGTH 64 +#define HTTP_MAX_HEADER_VALUE_LENGTH 256 #define HTTP_RESPONSE_200_TEMPLATE \ "HTTP/1.1 200 OK\r\n" \ diff --git a/runtime/include/sandbox_receive_request.h b/runtime/include/sandbox_receive_request.h index 32371f0..b77acbd 100644 --- a/runtime/include/sandbox_receive_request.h +++ b/runtime/include/sandbox_receive_request.h @@ -78,7 +78,7 @@ sandbox_receive_request(struct sandbox *sandbox) #ifdef LOG_HTTP_PARSER debuglog("Sandbox: %lu http_parser_execute(%p, %p, %p, %zu\n)", sandbox->id, parser, settings, - &sandbox->request.base[sandbox->request.length], bytes_received); + &sandbox->request.buffer[sandbox->request.length], bytes_received); #endif size_t bytes_parsed = http_parser_execute(parser, settings, (const char *)&request->buffer[request_length], diff --git a/runtime/src/current_sandbox.c b/runtime/src/current_sandbox.c index 8198274..2fa392d 100644 --- a/runtime/src/current_sandbox.c +++ b/runtime/src/current_sandbox.c @@ -187,7 +187,7 @@ err: return NULL; } -static inline void +extern noreturn void current_sandbox_fini() { struct sandbox *sandbox = current_sandbox_get(); diff --git a/runtime/src/http_parser_settings.c b/runtime/src/http_parser_settings.c index e09f976..e55c102 100644 --- a/runtime/src/http_parser_settings.c +++ b/runtime/src/http_parser_settings.c @@ -28,7 +28,6 @@ http_parser_settings_on_url(http_parser *parser, const char *at, size_t length) #ifdef LOG_HTTP_PARSER debuglog("sandbox: %lu, length: %zu, Content \"%.*s\"\n", sandbox->id, length, (int)length, at); - assert(strncmp(sandbox->module->name, (at + 1), length - 1) == 0); #endif return 0; diff --git a/runtime/src/libc/wasi_impl_serverless.c b/runtime/src/libc/wasi_impl_serverless.c index ca0a89a..8799f10 100644 --- a/runtime/src/libc/wasi_impl_serverless.c +++ b/runtime/src/libc/wasi_impl_serverless.c @@ -1064,9 +1064,8 @@ wasi_snapshot_preview1_backing_poll_oneoff(wasi_context_t *context, const __wasi noreturn void wasi_snapshot_preview1_backing_proc_exit(wasi_context_t *context, __wasi_exitcode_t exitcode) { - struct sandbox *s = current_sandbox_get(); - s->return_value = exitcode; - siglongjmp(s->ctxt.start_buf, WASM_TRAP_EXIT); + current_sandbox_fini(); + assert(0); } /** diff --git a/runtime/src/sledge_abi.c b/runtime/src/sledge_abi.c index 59a2785..5cdf918 100644 --- a/runtime/src/sledge_abi.c +++ b/runtime/src/sledge_abi.c @@ -921,7 +921,8 @@ sledge_abi__wasi_snapshot_preview1_poll_oneoff(__wasi_size_t in_baseoffset, __wa EXPORT void sledge_abi__wasi_snapshot_preview1_proc_exit(__wasi_exitcode_t exitcode) { - wasi_unsupported_syscall(__func__); + struct sandbox *sandbox = current_sandbox_get(); + wasi_snapshot_preview1_backing_proc_exit(sandbox->wasi_context, exitcode); } /** diff --git a/tests/html/.gitignore b/tests/html/.gitignore new file mode 100644 index 0000000..26cdcd9 --- /dev/null +++ b/tests/html/.gitignore @@ -0,0 +1,3 @@ +res +perf.data +perf.data.old diff --git a/tests/html/Makefile b/tests/html/Makefile new file mode 100644 index 0000000..d9cd37b --- /dev/null +++ b/tests/html/Makefile @@ -0,0 +1,47 @@ +RUNTIME_DIR=../../runtime/ +SLEDGE_BINARY_DIR=${RUNTIME_DIR}/bin +SLEDGE_TESTS_DIR=${RUNTIME_DIR}/tests +HOSTNAME=localhost +DURATION_SEC=15 + +all: run + +clean: + make -C ${RUNTIME_DIR} clean + make -C ${SLEDGE_TESTS_DIR} clean + rm -f ${SLEDGE_BINARY_DIR}/html.wasm.so + +${SLEDGE_BINARY_DIR}/sledgert: + make -C ${RUNTIME_DIR} runtime + +.PHONY: sledgert +sledgert: ${SLEDGE_BINARY_DIR}/sledgert + +${SLEDGE_BINARY_DIR}/html.wasm.so: + make -C ../../applications html.install + +.PHONY: html +html: ${SLEDGE_BINARY_DIR}/html.wasm.so + +run: sledgert html + LD_LIBRARY_PATH=${SLEDGE_BINARY_DIR} ${SLEDGE_BINARY_DIR}/sledgert spec.json + +debug: sledgert html + SLEDGE_DISABLE_PREEMPTION=true SLEDGE_NWORKERS=1 \ + LD_LIBRARY_PATH=${SLEDGE_BINARY_DIR} gdb ${SLEDGE_BINARY_DIR}/sledgert \ + --eval-command="handle SIGUSR1 noprint nostop" \ + --eval-command="handle SIGPIPE noprint nostop" \ + --eval-command="set pagination off" \ + --eval-command="run spec.json" + +client-fib10-once: + echo "10" | http :1337 + +client-fib40-once: + echo "40" | http :1337 + +client-preempt: + (echo "40" | http :10040 &); echo "10" | http :1337 + +client-fib10-multi: + hey -z ${DURATION_SEC}s -cpus 4 -c 100 -t 0 -o csv -m GET -d "10\n" "http://${HOSTNAME}:1337" diff --git a/tests/html/edf_nopreemption.env b/tests/html/edf_nopreemption.env new file mode 100644 index 0000000..eeba531 --- /dev/null +++ b/tests/html/edf_nopreemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=true diff --git a/tests/html/edf_preemption.env b/tests/html/edf_preemption.env new file mode 100644 index 0000000..302a324 --- /dev/null +++ b/tests/html/edf_preemption.env @@ -0,0 +1,3 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=false +SLEDGE_SIGALRM_HANDLER=TRIAGED diff --git a/tests/html/fifo_nopreemption.env b/tests/html/fifo_nopreemption.env new file mode 100644 index 0000000..a572a70 --- /dev/null +++ b/tests/html/fifo_nopreemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=true diff --git a/tests/html/fifo_preemption.env b/tests/html/fifo_preemption.env new file mode 100644 index 0000000..eb1298f --- /dev/null +++ b/tests/html/fifo_preemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=false diff --git a/tests/html/install.sh b/tests/html/install.sh new file mode 100755 index 0000000..0cbcfe8 --- /dev/null +++ b/tests/html/install.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if ! command -v hey > /dev/null; then + HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 + wget $HEY_URL -O hey + chmod +x hey + + if [[ $(whoami) == "root" ]]; then + mv hey /usr/bin/hey + else + sudo mv hey /usr/bin/hey + fi +fi diff --git a/tests/html/spec.json b/tests/html/spec.json new file mode 100644 index 0000000..d5e8b30 --- /dev/null +++ b/tests/html/spec.json @@ -0,0 +1,13 @@ +[ + { + "name": "html", + "path": "html.wasm.so", + "port": 1337, + "expected-execution-us": 10000000, + "admissions-percentile": 70, + "relative-deadline-us": 20000000, + "http-req-size": 1024, + "http-resp-size": 102400, + "http-resp-content-type": "text/html" + } +]