diff --git a/runtime/include/auto_buf.h b/runtime/include/auto_buf.h index 9071d250..74095fb5 100644 --- a/runtime/include/auto_buf.h +++ b/runtime/include/auto_buf.h @@ -1,5 +1,6 @@ #pragma once +#include "likely.h" #include #include #include diff --git a/runtime/include/execution_regression.h b/runtime/include/execution_regression.h index ab8c8684..deb81592 100644 --- a/runtime/include/execution_regression.h +++ b/runtime/include/execution_regression.h @@ -11,9 +11,10 @@ get_regression_prediction(struct http_session *session) /* Default Pre-processing - Extract payload size */ const int payload_size = session->http_request.body_length; - const double regression_params[2] = {payload_size, session->param2}; + const double regression_params[2] = {payload_size, session->paregression_paramram2}; - /* Regression */ + /* Perform Linear Regression using the factors provided by the regressor performed AoT on Matlab using training + * tenant-given dataset */ const struct regression_model model = session->route->regr_model; const uint64_t prediction = (regression_params[0] / model.scale * model.beta1 + regression_params[1] / model.scale * model.beta2) diff --git a/runtime/include/http_session.h b/runtime/include/http_session.h index 356e9422..8c760541 100644 --- a/runtime/include/http_session.h +++ b/runtime/include/http_session.h @@ -59,7 +59,7 @@ struct http_session { uint64_t response_sent_timestamp; bool did_preprocessing; uint64_t preprocessing_duration; - double param2; + double regression_param; /* Calculated in tenant preprocessing logic if provided */ }; extern void http_session_perf_log_print_entry(struct http_session *http_session); diff --git a/runtime/include/module.h b/runtime/include/module.h index 41f104ae..390379d8 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -112,7 +112,8 @@ static inline void module_initialize_pools(struct module *module) { /* Create only a single pool for the preprocessing module, since it is executed only by the event core. */ - for (int i = 0; i < (module->type == APP_MODULE ? runtime_worker_threads_count : 1); i++) { + const int n = module->type == APP_MODULE ? runtime_worker_threads_count : 1; + for (int i = 0; i < n; i++) { wasm_memory_pool_init(&module->pools[i].memory, false); wasm_stack_pool_init(&module->pools[i].stack, false); } @@ -121,7 +122,8 @@ module_initialize_pools(struct module *module) static inline void module_deinitialize_pools(struct module *module) { - for (int i = 0; i < (module->type == APP_MODULE ? runtime_worker_threads_count : 1); i++) { + const int n = module->type == APP_MODULE ? runtime_worker_threads_count : 1; + for (int i = 0; i < n; i++) { wasm_memory_pool_deinit(&module->pools[i].memory); wasm_stack_pool_deinit(&module->pools[i].stack); } diff --git a/runtime/include/sandbox_set_as_error.h b/runtime/include/sandbox_set_as_error.h index bc09b0d9..68a13b79 100644 --- a/runtime/include/sandbox_set_as_error.h +++ b/runtime/include/sandbox_set_as_error.h @@ -49,10 +49,11 @@ sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state) /* State Change Bookkeeping */ assert(now > sandbox->timestamp_of.last_state_change); sandbox->last_state_duration = now - sandbox->timestamp_of.last_state_change; - if (last_state == SANDBOX_RUNNING_SYS) + if (last_state == SANDBOX_RUNNING_SYS) { sandbox->remaining_exec = (sandbox->remaining_exec > sandbox->last_state_duration) ? sandbox->remaining_exec - sandbox->last_state_duration : 0; + } sandbox->duration_of_state[last_state] += sandbox->last_state_duration; sandbox->timestamp_of.last_state_change = now; sandbox_state_history_append(&sandbox->state_history, SANDBOX_ERROR); diff --git a/runtime/src/tenant.c b/runtime/src/tenant.c index 6b84b823..98e48cdf 100644 --- a/runtime/src/tenant.c +++ b/runtime/src/tenant.c @@ -53,7 +53,7 @@ tenant_preprocess(struct http_session *session) } else if ((errno == ERANGE && (num == LONG_MAX || num == LONG_MIN)) || (errno != 0 && num == 0)) { perror("strtol"); } else { - session->param2 = num; + session->regression_param = num; } session->http_request.cursor = 0;