From 178bef818fe33ff4546abe22a3ea5d647affc239 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 19 Mar 2020 13:13:37 -0400 Subject: [PATCH] feat: add relative_deadline_us to json and module --- runtime/include/module.h | 10 +++++----- runtime/src/module.c | 26 +++++++++++++++----------- runtime/tests/test_armcifar10.json | 1 + runtime/tests/test_empty.json | 1 + runtime/tests/test_fibonacci.json | 1 + runtime/tests/test_gocr.json | 1 + runtime/tests/test_modules.json | 24 ++++++++++++++++++++++-- runtime/tests/test_sodlpd.json | 1 + runtime/tests/test_sodresize.json | 1 + runtime/tests/test_work.json | 1 + runtime/tests/test_work100k.json | 3 ++- runtime/tests/test_work10k.json | 1 + runtime/tests/test_work1k.json | 1 + runtime/tests/test_work1m.json | 1 + 14 files changed, 54 insertions(+), 19 deletions(-) diff --git a/runtime/include/module.h b/runtime/include/module.h index 57dcd35..146af17 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -10,9 +10,9 @@ struct module { char path[MODULE__MAX_PATH_LENGTH]; void * dynamic_library_handle; // Handle to the *.so of the serverless function i32 argument_count; - u32 stack_size; // a specification? - u64 max_memory; // perhaps a specification of the module. (max 4GB) - u32 timeout; // again part of the module specification. + u32 stack_size; // a specification? + u64 max_memory; // perhaps a specification of the module. (max 4GB) + u32 relative_deadline_us; u32 reference_count; // ref count how many instances exist here. struct indirect_table_entry indirect_table[INDIRECT_TABLE_SIZE]; struct sockaddr_in socket_address; @@ -183,8 +183,8 @@ module_set_http_info(struct module *module, int request_count, char *request_hea ***************************************/ void module_free(struct module *module); -struct module *module_new(char *mod_name, char *mod_path, i32 argument_count, u32 stack_sz, u32 max_heap, u32 timeout, - int port, int req_sz, int resp_sz); +struct module *module_new(char *mod_name, char *mod_path, i32 argument_count, u32 stack_sz, u32 max_heap, + u32 relative_deadline_us, int port, int req_sz, int resp_sz); int module_new_from_json(char *filename); #endif /* SFRT_MODULE_H */ diff --git a/runtime/src/module.c b/runtime/src/module.c index f256335..2acd33a 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -93,14 +93,14 @@ module_free(struct module *module) * @param argument_count * @param stack_size * @param max_memory - * @param timeout + * @param relative_deadline_us * @param port * @param request_size * @returns A new module or NULL in case of failure **/ struct module * -module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 timeout, int port, - int request_size, int response_size) +module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 relative_deadline_us, + int port, int request_size, int response_size) { struct module *module = (struct module *)malloc(sizeof(struct module)); if (!module) return NULL; @@ -131,12 +131,12 @@ module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_m strncpy(module->name, name, MODULE__MAX_NAME_LENGTH); strncpy(module->path, path, MODULE__MAX_PATH_LENGTH); - module->argument_count = argument_count; - module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size); - module->max_memory = max_memory == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory; - module->timeout = timeout; - module->socket_descriptor = -1; - module->port = port; + module->argument_count = argument_count; + module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size); + module->max_memory = max_memory == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory; + module->relative_deadline_us = relative_deadline_us; + module->socket_descriptor = -1; + module->port = port; if (request_size == 0) request_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE; if (response_size == 0) response_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE; module->max_request_size = request_size; @@ -239,6 +239,7 @@ module_new_from_json(char *file_name) i32 response_size = 0; i32 argument_count = 0; u32 port = 0; + u32 relative_deadline_us = 0; i32 is_active = 0; i32 request_count = 0; i32 response_count = 0; @@ -266,6 +267,9 @@ module_new_from_json(char *file_name) argument_count = atoi(val); } else if (strcmp(key, "active") == 0) { is_active = (strcmp(val, "yes") == 0); + } else if (strcmp(key, "relative-deadline-us") == 0) { + relative_deadline_us = atoi(val); + printf("Set relative deadline to %d us\n", relative_deadline_us); } else if (strcmp(key, "http-req-headers") == 0) { assert(tokens[i + j + 1].type == JSMN_ARRAY); assert(tokens[i + j + 1].size <= HTTP__MAX_HEADER_COUNT); @@ -310,8 +314,8 @@ module_new_from_json(char *file_name) if (is_active == 0) continue; // Allocate a module based on the values from the JSON - struct module *module = module_new(module_name, module_path, argument_count, 0, 0, 0, port, - request_size, response_size); + struct module *module = module_new(module_name, module_path, argument_count, 0, 0, relative_deadline_us, + port, request_size, response_size); assert(module); module_set_http_info(module, request_count, request_headers, request_content_type, response_count, reponse_headers, response_content_type); diff --git a/runtime/tests/test_armcifar10.json b/runtime/tests/test_armcifar10.json index 6f2544b..240e584 100644 --- a/runtime/tests/test_armcifar10.json +++ b/runtime/tests/test_armcifar10.json @@ -3,6 +3,7 @@ "name": "cifar10", "path": "cifar10_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "image/png", diff --git a/runtime/tests/test_empty.json b/runtime/tests/test_empty.json index 5f12a3f..b2b4a20 100644 --- a/runtime/tests/test_empty.json +++ b/runtime/tests/test_empty.json @@ -3,6 +3,7 @@ "name": "empty", "path": "empty_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain", diff --git a/runtime/tests/test_fibonacci.json b/runtime/tests/test_fibonacci.json index 7a59076..cbf4826 100644 --- a/runtime/tests/test_fibonacci.json +++ b/runtime/tests/test_fibonacci.json @@ -3,6 +3,7 @@ "name": "fibonacci", "path": "fibonacci_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain", diff --git a/runtime/tests/test_gocr.json b/runtime/tests/test_gocr.json index b27e828..5dfc241 100644 --- a/runtime/tests/test_gocr.json +++ b/runtime/tests/test_gocr.json @@ -3,6 +3,7 @@ "name": "gocr", "path": "gocr_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "image/png", diff --git a/runtime/tests/test_modules.json b/runtime/tests/test_modules.json index 6365e01..b7c7cb6 100644 --- a/runtime/tests/test_modules.json +++ b/runtime/tests/test_modules.json @@ -1,8 +1,9 @@ -{ +({ "active": "no", "name": "adpcm", "path": "adpcm_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -10,6 +11,7 @@ "name": "bitcount", "path": "bitcount_wasm.so", "port": 10002, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -17,6 +19,7 @@ "name": "basic_math", "path": "basic_math_wasm.so", "port": 10004, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -24,6 +27,7 @@ "name": "binarytrees", "path": "binarytrees_wasm.so", "port": 10006, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -31,6 +35,7 @@ "name": "crc", "path": "crc_wasm.so", "port": 10008, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -38,6 +43,7 @@ "name": "dijkstra", "path": "dijkstra_wasm.so", "port": 10010, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -45,6 +51,7 @@ "name": "forever", "path": "forever_wasm.so", "port": 10012, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -52,6 +59,7 @@ "name": "fornever", "path": "forever_wasm.so", "port": 10014, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -59,6 +67,7 @@ "name": "fft", "path": "fft_wasm.so", "port": 10016, + "relative-deadline-us": 50000, "argsize": 3 }, { @@ -66,6 +75,7 @@ "name": "function_pointers", "path": "function_pointers_wasm.so", "port": 10018, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -73,6 +83,7 @@ "name": "gsm", "path": "gsm_wasm.so", "port": 10020, + "relative-deadline-us": 50000, "argsize": 4 }, { @@ -80,6 +91,7 @@ "name": "libjpeg", "path": "libjpeg_wasm.so", "port": 10022, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -87,6 +99,7 @@ "name": "mandelbrot", "path": "mandelbrot_wasm.so", "port": 10024, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -94,6 +107,7 @@ "name": "matrix_multiply", "path": "matrix_multiply_wasm.so", "port": 10026, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -101,6 +115,7 @@ "name": "particia", "path": "partricia_wasm.so", "port": 10028, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -108,6 +123,7 @@ "name": "sqlite", "path": "sqlite_wasm.so", "port": 10030, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -115,6 +131,7 @@ "name": "stringsearch", "path": "stringsearch_wasm.so", "port": 10032, + "relative-deadline-us": 50000, "argsize": 1 }, { @@ -122,6 +139,7 @@ "name": "filesys", "path": "filesys_wasm.so", "port": 10034, + "relative-deadline-us": 50000, "argsize": 3 }, { @@ -129,6 +147,7 @@ "name": "sockserver", "path": "sockserver_wasm.so", "port": 10036, + "relative-deadline-us": 50000, "argsize": 2 }, { @@ -136,5 +155,6 @@ "name": "sockclient", "path": "sockclient_wasm.so", "port": 10038, + "relative-deadline-us": 50000, "argsize": 3 -} \ No newline at end of file +}) diff --git a/runtime/tests/test_sodlpd.json b/runtime/tests/test_sodlpd.json index 5f26f56..69ab432 100644 --- a/runtime/tests/test_sodlpd.json +++ b/runtime/tests/test_sodlpd.json @@ -3,6 +3,7 @@ "name": "lpd", "path": "lpd_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "image/jpeg", diff --git a/runtime/tests/test_sodresize.json b/runtime/tests/test_sodresize.json index 8f2c648..8fc29ae 100644 --- a/runtime/tests/test_sodresize.json +++ b/runtime/tests/test_sodresize.json @@ -3,6 +3,7 @@ "name": "resize", "path": "resize_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "image/jpeg", diff --git a/runtime/tests/test_work.json b/runtime/tests/test_work.json index 30e37a8..43804b2 100644 --- a/runtime/tests/test_work.json +++ b/runtime/tests/test_work.json @@ -3,6 +3,7 @@ "name": "work", "path": "work_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain", diff --git a/runtime/tests/test_work100k.json b/runtime/tests/test_work100k.json index ae89abd..be69f24 100644 --- a/runtime/tests/test_work100k.json +++ b/runtime/tests/test_work100k.json @@ -2,7 +2,8 @@ "active": "yes", "name": "work100k", "path": "work100k_wasm.so", - "port": 10000, + "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain", diff --git a/runtime/tests/test_work10k.json b/runtime/tests/test_work10k.json index bc854c9..67dd917 100644 --- a/runtime/tests/test_work10k.json +++ b/runtime/tests/test_work10k.json @@ -3,6 +3,7 @@ "name": "work10k", "path": "work10k_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain", diff --git a/runtime/tests/test_work1k.json b/runtime/tests/test_work1k.json index 4393ef2..c2e37d9 100644 --- a/runtime/tests/test_work1k.json +++ b/runtime/tests/test_work1k.json @@ -3,6 +3,7 @@ "name": "work1k", "path": "work1k_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain", diff --git a/runtime/tests/test_work1m.json b/runtime/tests/test_work1m.json index e25605a..d91bdc9 100644 --- a/runtime/tests/test_work1m.json +++ b/runtime/tests/test_work1m.json @@ -3,6 +3,7 @@ "name": "work1m", "path": "work1m_wasm.so", "port": 10000, + "relative-deadline-us": 50000, "argsize": 1, "http-req-headers": [], "http-req-content-type": "text/plain",