feat: add relative_deadline_us to json and module

main
Sean McBride 5 years ago
parent 0bd22a2e9c
commit 178bef818f

@ -10,9 +10,9 @@ struct module {
char path[MODULE__MAX_PATH_LENGTH]; char path[MODULE__MAX_PATH_LENGTH];
void * dynamic_library_handle; // Handle to the *.so of the serverless function void * dynamic_library_handle; // Handle to the *.so of the serverless function
i32 argument_count; i32 argument_count;
u32 stack_size; // a specification? u32 stack_size; // a specification?
u64 max_memory; // perhaps a specification of the module. (max 4GB) u64 max_memory; // perhaps a specification of the module. (max 4GB)
u32 timeout; // again part of the module specification. u32 relative_deadline_us;
u32 reference_count; // ref count how many instances exist here. u32 reference_count; // ref count how many instances exist here.
struct indirect_table_entry indirect_table[INDIRECT_TABLE_SIZE]; struct indirect_table_entry indirect_table[INDIRECT_TABLE_SIZE];
struct sockaddr_in socket_address; 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); 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, struct module *module_new(char *mod_name, char *mod_path, i32 argument_count, u32 stack_sz, u32 max_heap,
int port, int req_sz, int resp_sz); u32 relative_deadline_us, int port, int req_sz, int resp_sz);
int module_new_from_json(char *filename); int module_new_from_json(char *filename);
#endif /* SFRT_MODULE_H */ #endif /* SFRT_MODULE_H */

@ -93,14 +93,14 @@ module_free(struct module *module)
* @param argument_count * @param argument_count
* @param stack_size * @param stack_size
* @param max_memory * @param max_memory
* @param timeout * @param relative_deadline_us
* @param port * @param port
* @param request_size * @param request_size
* @returns A new module or NULL in case of failure * @returns A new module or NULL in case of failure
**/ **/
struct module * struct module *
module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 timeout, int port, module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_memory, u32 relative_deadline_us,
int request_size, int response_size) int port, int request_size, int response_size)
{ {
struct module *module = (struct module *)malloc(sizeof(struct module)); struct module *module = (struct module *)malloc(sizeof(struct module));
if (!module) return NULL; 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->name, name, MODULE__MAX_NAME_LENGTH);
strncpy(module->path, path, MODULE__MAX_PATH_LENGTH); strncpy(module->path, path, MODULE__MAX_PATH_LENGTH);
module->argument_count = argument_count; module->argument_count = argument_count;
module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size); 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->max_memory = max_memory == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory;
module->timeout = timeout; module->relative_deadline_us = relative_deadline_us;
module->socket_descriptor = -1; module->socket_descriptor = -1;
module->port = port; module->port = port;
if (request_size == 0) request_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE; if (request_size == 0) request_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
if (response_size == 0) response_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE; if (response_size == 0) response_size = MODULE__DEFAULT_REQUEST_RESPONSE_SIZE;
module->max_request_size = request_size; module->max_request_size = request_size;
@ -239,6 +239,7 @@ module_new_from_json(char *file_name)
i32 response_size = 0; i32 response_size = 0;
i32 argument_count = 0; i32 argument_count = 0;
u32 port = 0; u32 port = 0;
u32 relative_deadline_us = 0;
i32 is_active = 0; i32 is_active = 0;
i32 request_count = 0; i32 request_count = 0;
i32 response_count = 0; i32 response_count = 0;
@ -266,6 +267,9 @@ module_new_from_json(char *file_name)
argument_count = atoi(val); argument_count = atoi(val);
} else if (strcmp(key, "active") == 0) { } else if (strcmp(key, "active") == 0) {
is_active = (strcmp(val, "yes") == 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) { } else if (strcmp(key, "http-req-headers") == 0) {
assert(tokens[i + j + 1].type == JSMN_ARRAY); assert(tokens[i + j + 1].type == JSMN_ARRAY);
assert(tokens[i + j + 1].size <= HTTP__MAX_HEADER_COUNT); 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; if (is_active == 0) continue;
// Allocate a module based on the values from the JSON // 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, struct module *module = module_new(module_name, module_path, argument_count, 0, 0, relative_deadline_us,
request_size, response_size); port, request_size, response_size);
assert(module); assert(module);
module_set_http_info(module, request_count, request_headers, request_content_type, response_count, module_set_http_info(module, request_count, request_headers, request_content_type, response_count,
reponse_headers, response_content_type); reponse_headers, response_content_type);

@ -3,6 +3,7 @@
"name": "cifar10", "name": "cifar10",
"path": "cifar10_wasm.so", "path": "cifar10_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "image/png", "http-req-content-type": "image/png",

@ -3,6 +3,7 @@
"name": "empty", "name": "empty",
"path": "empty_wasm.so", "path": "empty_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

@ -3,6 +3,7 @@
"name": "fibonacci", "name": "fibonacci",
"path": "fibonacci_wasm.so", "path": "fibonacci_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

@ -3,6 +3,7 @@
"name": "gocr", "name": "gocr",
"path": "gocr_wasm.so", "path": "gocr_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "image/png", "http-req-content-type": "image/png",

@ -1,8 +1,9 @@
{ ({
"active": "no", "active": "no",
"name": "adpcm", "name": "adpcm",
"path": "adpcm_wasm.so", "path": "adpcm_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -10,6 +11,7 @@
"name": "bitcount", "name": "bitcount",
"path": "bitcount_wasm.so", "path": "bitcount_wasm.so",
"port": 10002, "port": 10002,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -17,6 +19,7 @@
"name": "basic_math", "name": "basic_math",
"path": "basic_math_wasm.so", "path": "basic_math_wasm.so",
"port": 10004, "port": 10004,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -24,6 +27,7 @@
"name": "binarytrees", "name": "binarytrees",
"path": "binarytrees_wasm.so", "path": "binarytrees_wasm.so",
"port": 10006, "port": 10006,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -31,6 +35,7 @@
"name": "crc", "name": "crc",
"path": "crc_wasm.so", "path": "crc_wasm.so",
"port": 10008, "port": 10008,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -38,6 +43,7 @@
"name": "dijkstra", "name": "dijkstra",
"path": "dijkstra_wasm.so", "path": "dijkstra_wasm.so",
"port": 10010, "port": 10010,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -45,6 +51,7 @@
"name": "forever", "name": "forever",
"path": "forever_wasm.so", "path": "forever_wasm.so",
"port": 10012, "port": 10012,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -52,6 +59,7 @@
"name": "fornever", "name": "fornever",
"path": "forever_wasm.so", "path": "forever_wasm.so",
"port": 10014, "port": 10014,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -59,6 +67,7 @@
"name": "fft", "name": "fft",
"path": "fft_wasm.so", "path": "fft_wasm.so",
"port": 10016, "port": 10016,
"relative-deadline-us": 50000,
"argsize": 3 "argsize": 3
}, },
{ {
@ -66,6 +75,7 @@
"name": "function_pointers", "name": "function_pointers",
"path": "function_pointers_wasm.so", "path": "function_pointers_wasm.so",
"port": 10018, "port": 10018,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -73,6 +83,7 @@
"name": "gsm", "name": "gsm",
"path": "gsm_wasm.so", "path": "gsm_wasm.so",
"port": 10020, "port": 10020,
"relative-deadline-us": 50000,
"argsize": 4 "argsize": 4
}, },
{ {
@ -80,6 +91,7 @@
"name": "libjpeg", "name": "libjpeg",
"path": "libjpeg_wasm.so", "path": "libjpeg_wasm.so",
"port": 10022, "port": 10022,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -87,6 +99,7 @@
"name": "mandelbrot", "name": "mandelbrot",
"path": "mandelbrot_wasm.so", "path": "mandelbrot_wasm.so",
"port": 10024, "port": 10024,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -94,6 +107,7 @@
"name": "matrix_multiply", "name": "matrix_multiply",
"path": "matrix_multiply_wasm.so", "path": "matrix_multiply_wasm.so",
"port": 10026, "port": 10026,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -101,6 +115,7 @@
"name": "particia", "name": "particia",
"path": "partricia_wasm.so", "path": "partricia_wasm.so",
"port": 10028, "port": 10028,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -108,6 +123,7 @@
"name": "sqlite", "name": "sqlite",
"path": "sqlite_wasm.so", "path": "sqlite_wasm.so",
"port": 10030, "port": 10030,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -115,6 +131,7 @@
"name": "stringsearch", "name": "stringsearch",
"path": "stringsearch_wasm.so", "path": "stringsearch_wasm.so",
"port": 10032, "port": 10032,
"relative-deadline-us": 50000,
"argsize": 1 "argsize": 1
}, },
{ {
@ -122,6 +139,7 @@
"name": "filesys", "name": "filesys",
"path": "filesys_wasm.so", "path": "filesys_wasm.so",
"port": 10034, "port": 10034,
"relative-deadline-us": 50000,
"argsize": 3 "argsize": 3
}, },
{ {
@ -129,6 +147,7 @@
"name": "sockserver", "name": "sockserver",
"path": "sockserver_wasm.so", "path": "sockserver_wasm.so",
"port": 10036, "port": 10036,
"relative-deadline-us": 50000,
"argsize": 2 "argsize": 2
}, },
{ {
@ -136,5 +155,6 @@
"name": "sockclient", "name": "sockclient",
"path": "sockclient_wasm.so", "path": "sockclient_wasm.so",
"port": 10038, "port": 10038,
"relative-deadline-us": 50000,
"argsize": 3 "argsize": 3
} })

@ -3,6 +3,7 @@
"name": "lpd", "name": "lpd",
"path": "lpd_wasm.so", "path": "lpd_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "image/jpeg", "http-req-content-type": "image/jpeg",

@ -3,6 +3,7 @@
"name": "resize", "name": "resize",
"path": "resize_wasm.so", "path": "resize_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "image/jpeg", "http-req-content-type": "image/jpeg",

@ -3,6 +3,7 @@
"name": "work", "name": "work",
"path": "work_wasm.so", "path": "work_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

@ -3,6 +3,7 @@
"name": "work100k", "name": "work100k",
"path": "work100k_wasm.so", "path": "work100k_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

@ -3,6 +3,7 @@
"name": "work10k", "name": "work10k",
"path": "work10k_wasm.so", "path": "work10k_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

@ -3,6 +3,7 @@
"name": "work1k", "name": "work1k",
"path": "work1k_wasm.so", "path": "work1k_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

@ -3,6 +3,7 @@
"name": "work1m", "name": "work1m",
"path": "work1m_wasm.so", "path": "work1m_wasm.so",
"port": 10000, "port": 10000,
"relative-deadline-us": 50000,
"argsize": 1, "argsize": 1,
"http-req-headers": [], "http-req-headers": [],
"http-req-content-type": "text/plain", "http-req-content-type": "text/plain",

Loading…
Cancel
Save