From 44e4026df238bf619ec562753bcf613e065dc56d Mon Sep 17 00:00:00 2001 From: xiaosuGW Date: Wed, 4 Aug 2021 17:28:53 -0400 Subject: [PATCH] implement multiple linear chain --- runtime/src/module.c | 17 ++++- runtime/tests/mulitple_linear_chain.json | 90 ++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 runtime/tests/mulitple_linear_chain.json diff --git a/runtime/src/module.c b/runtime/src/module.c index d53f3e2..a371a64 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -405,6 +405,7 @@ module_new_from_json(char *file_name) uint32_t expected_execution_us = 0; int admissions_percentile = 50; bool is_active = false; + bool is_tail_module = false; int32_t request_count = 0; int32_t response_count = 0; int j = 1; @@ -453,6 +454,15 @@ module_new_from_json(char *file_name) } else { panic("Expected active key to be a JSON boolean, was %s\n", val); } + } else if (strcmp(key, "tail_module") == 0) { + assert(tokens[i + j + 1].type == JSMN_PRIMITIVE); + if (val[0] == 't') { + is_tail_module = true; + } else if (val[0] == 'f') { + is_tail_module = false; + } else { + panic("Expected tail_module key to be a JSON boolean, was %s\n", val); + } } else if (strcmp(key, "relative-deadline-us") == 0) { int64_t buffer = strtoll(val, NULL, 10); if (buffer < 0 || buffer > (int64_t)RUNTIME_RELATIVE_DEADLINE_US_MAX) @@ -562,7 +572,12 @@ module_new_from_json(char *file_name) if (tail_module != NULL) { tail_module->next_module = module; } tail_module = module; tail_module->next_module = NULL; - + + /* if this is the tail module, reset tail_module to NULL to build another new chain */ + if (is_tail_module) { + tail_module = NULL; + } + module_set_http_info(module, request_count, request_headers, request_content_type, response_count, reponse_headers, response_content_type); module_count++; diff --git a/runtime/tests/mulitple_linear_chain.json b/runtime/tests/mulitple_linear_chain.json new file mode 100644 index 0000000..a20637c --- /dev/null +++ b/runtime/tests/mulitple_linear_chain.json @@ -0,0 +1,90 @@ +{ + "active": true, + "name": "resize", + "path": "resize_wasm.so", + "port": 10000, + "relative-deadline-us": 50000, + "argsize": 1, + "http-req-headers": [], + "http-req-content-type": "image/jpeg", + "http-req-size": 1024000, + "http-resp-headers": [], + "http-resp-size": 1024000, + "http-resp-content-type": "image/png" +}, +{ + "active": true, + "name": "png2bmp", + "path": "C-Image-Manip_wasm.so", + "port": 10001, + "relative-deadline-us": 60000, + "argsize": 1, + "http-req-headers": [], + "http-req-content-type": "image/png", + "http-req-size": 4096000, + "http-resp-headers": [], + "http-resp-size": 4096000, + "http-resp-content-type": "image/bmp" +}, +{ + "active": true, + "name": "cifar10", + "path": "cifar10_wasm.so", + "port": 10002, + "relative-deadline-us": 50000, + "argsize": 1, + "http-req-headers": [], + "http-req-content-type": "image/bmp", + "http-req-size": 4096000, + "http-resp-headers": [], + "http-resp-size": 1024, + "http-resp-content-type": "text/plain", + "tail-module": true +}, +{ + "active": true, + "name": "fibonacci", + "path": "fibonacci_wasm.so", + "port": 10003, + "expected-execution-us": 600, + "relative-deadline-us": 2000, + "argsize": 2, + "http-req-headers": [], + "http-req-content-type": "text/plain", + "http-req-size": 1024, + "http-resp-headers": [], + "http-resp-size": 1024, + "http-resp-content-type": "text/plain" +}, +{ + "active": true, + "name": "fibonacci2", + "path": "fibonacci2_wasm.so", + "port": 10004, + "expected-execution-us": 600, + "relative-deadline-us": 2000, + "argsize": 2, + "http-req-headers": [], + "http-req-content-type": "text/plain", + "http-req-size": 1024, + "http-resp-headers": [], + "http-resp-size": 1024, + "http-resp-content-type": "text/plain" +}, +{ + "active": true, + "name": "fibonacci3", + "path": "fibonacci3_wasm.so", + "port": 10005, + "expected-execution-us": 600, + "relative-deadline-us": 2000, + "argsize": 2, + "http-req-headers": [], + "http-req-content-type": "text/plain", + "http-req-size": 1024, + "http-resp-headers": [], + "http-resp-size": 1024, + "http-resp-content-type": "text/plain", + "tail-module": true +} +