Addressed Gabe's comments

pull/385/head
Emil Abbasov 1 year ago
parent fb6516febd
commit c990be467c

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "likely.h"
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

@ -11,9 +11,10 @@ get_regression_prediction(struct http_session *session)
/* Default Pre-processing - Extract payload size */ /* Default Pre-processing - Extract payload size */
const int payload_size = session->http_request.body_length; 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 struct regression_model model = session->route->regr_model;
const uint64_t prediction = (regression_params[0] / model.scale * model.beta1 const uint64_t prediction = (regression_params[0] / model.scale * model.beta1
+ regression_params[1] / model.scale * model.beta2) + regression_params[1] / model.scale * model.beta2)

@ -59,7 +59,7 @@ struct http_session {
uint64_t response_sent_timestamp; uint64_t response_sent_timestamp;
bool did_preprocessing; bool did_preprocessing;
uint64_t preprocessing_duration; 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); extern void http_session_perf_log_print_entry(struct http_session *http_session);

@ -112,7 +112,8 @@ static inline void
module_initialize_pools(struct module *module) module_initialize_pools(struct module *module)
{ {
/* Create only a single pool for the preprocessing module, since it is executed only by the event core. */ /* 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_memory_pool_init(&module->pools[i].memory, false);
wasm_stack_pool_init(&module->pools[i].stack, false); wasm_stack_pool_init(&module->pools[i].stack, false);
} }
@ -121,7 +122,8 @@ module_initialize_pools(struct module *module)
static inline void static inline void
module_deinitialize_pools(struct module *module) 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_memory_pool_deinit(&module->pools[i].memory);
wasm_stack_pool_deinit(&module->pools[i].stack); wasm_stack_pool_deinit(&module->pools[i].stack);
} }

@ -49,10 +49,11 @@ sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state)
/* State Change Bookkeeping */ /* State Change Bookkeeping */
assert(now > sandbox->timestamp_of.last_state_change); assert(now > sandbox->timestamp_of.last_state_change);
sandbox->last_state_duration = 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->remaining_exec > sandbox->last_state_duration)
? sandbox->remaining_exec - sandbox->last_state_duration ? sandbox->remaining_exec - sandbox->last_state_duration
: 0; : 0;
}
sandbox->duration_of_state[last_state] += sandbox->last_state_duration; sandbox->duration_of_state[last_state] += sandbox->last_state_duration;
sandbox->timestamp_of.last_state_change = now; sandbox->timestamp_of.last_state_change = now;
sandbox_state_history_append(&sandbox->state_history, SANDBOX_ERROR); sandbox_state_history_append(&sandbox->state_history, SANDBOX_ERROR);

@ -53,7 +53,7 @@ tenant_preprocess(struct http_session *session)
} else if ((errno == ERANGE && (num == LONG_MAX || num == LONG_MIN)) || (errno != 0 && num == 0)) { } else if ((errno == ERANGE && (num == LONG_MAX || num == LONG_MIN)) || (errno != 0 && num == 0)) {
perror("strtol"); perror("strtol");
} else { } else {
session->param2 = num; session->regression_param = num;
} }
session->http_request.cursor = 0; session->http_request.cursor = 0;

Loading…
Cancel
Save