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];
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 */

@ -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);

@ -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",

@ -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",

@ -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",

@ -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",

@ -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
}
})

@ -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",

@ -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",

@ -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",

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

@ -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",

@ -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",

@ -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",

Loading…
Cancel
Save