From ba4f9e21197f3a5accd4c1388096095d229951d0 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Wed, 29 Jul 2020 13:46:39 -0400 Subject: [PATCH] feat: precomp module deadline cycles --- runtime/include/module.h | 3 ++- runtime/include/runtime.h | 1 + runtime/include/sandbox_request.h | 5 +---- runtime/src/module.c | 1 + 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/include/module.h b/runtime/include/module.h index 6fed543..2f1d239 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -32,7 +32,8 @@ struct module { uint32_t stack_size; /* a specification? */ uint64_t max_memory; /* perhaps a specification of the module. (max 4GB) */ uint32_t relative_deadline_us; - uint32_t reference_count; /* ref count how many instances exist here. */ + uint64_t relative_deadline; /* cycles */ + uint32_t reference_count; /* ref count how many instances exist here. */ struct indirect_table_entry indirect_table[INDIRECT_TABLE_SIZE]; struct sockaddr_in socket_address; int socket_descriptor; diff --git a/runtime/include/runtime.h b/runtime/include/runtime.h index 85a0680..52a28a0 100644 --- a/runtime/include/runtime.h +++ b/runtime/include/runtime.h @@ -14,6 +14,7 @@ #define RUNTIME_READ_WRITE_VECTOR_LENGTH 16 extern int runtime_epoll_file_descriptor; +extern float runtime_processor_speed_MHz; extern uint32_t runtime_total_worker_processors; extern pthread_t runtime_worker_threads[]; diff --git a/runtime/include/sandbox_request.h b/runtime/include/sandbox_request.h index 4fdd5c0..8055114 100644 --- a/runtime/include/sandbox_request.h +++ b/runtime/include/sandbox_request.h @@ -7,8 +7,6 @@ #include "module.h" #include "runtime.h" -extern float runtime_processor_speed_MHz; - struct sandbox_request { struct module * module; char * arguments; @@ -40,8 +38,7 @@ sandbox_request_allocate(struct module *module, char *arguments, int socket_desc sandbox_request->socket_descriptor = socket_descriptor; sandbox_request->socket_address = (struct sockaddr *)socket_address; sandbox_request->request_arrival_timestamp = request_arrival_timestamp; - sandbox_request->absolute_deadline = request_arrival_timestamp - + module->relative_deadline_us * runtime_processor_speed_MHz; + sandbox_request->absolute_deadline = request_arrival_timestamp + module->relative_deadline; debuglog("Allocating %lu of %s:%d\n", sandbox_request->request_arrival_timestamp, sandbox_request->module->name, sandbox_request->module->port); diff --git a/runtime/src/module.c b/runtime/src/module.c index a6ad84c..a20f0d3 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -166,6 +166,7 @@ module_new(char *name, char *path, int32_t argument_count, uint32_t stack_size, module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size); module->max_memory = max_memory == 0 ? ((uint64_t)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory; module->relative_deadline_us = relative_deadline_us; + module->relative_deadline = relative_deadline_us * runtime_processor_speed_MHz; module->socket_descriptor = -1; module->port = port;