feature: added SJF scheduler and Regression based prediction (#385)
* feature: added SJF scheduler added REGRESSION based prediction support * fix: error handling * fixed the default values for def.server when not given * fix: replace GET by POST for hey requests (fix by Xioasu) * - update .clang-format props to match composite (almost) - reformat C codes in the repo - refactor the format.sh script - fetch latest AWSM master * Addressed Gabe's comments * error handling for when model_scale and model_beta2 is zero * fix the multi-tenantcy-predictions run.sh script * - upgraded to LLVM_VERSION=13 both on sledge & AWSM - updated dockerfile, main.yaml - added new uninstall_llvm.sh script to ease LLVM removalmaster
parent
4ae8b02413
commit
6b0ba99e86
@ -1 +1 @@
|
||||
Subproject commit e2ba697861201f2aaca37460842ab5c34c8d1716
|
||||
Subproject commit e3abafa1e18b6d600fc0ca7e0810fea1f6621ea6
|
@ -1,18 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef ADMISSIONS_CONTROL
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef ADMISSIONS_CONTROL
|
||||
#define ADMISSIONS_CONTROL_GRANULARITY 1000000
|
||||
extern _Atomic uint64_t admissions_control_admitted;
|
||||
extern uint64_t admissions_control_capacity;
|
||||
#endif
|
||||
|
||||
void admissions_control_initialize(void);
|
||||
void admissions_control_add(uint64_t admissions_estimate);
|
||||
void admissions_control_subtract(uint64_t admissions_estimate);
|
||||
uint64_t admissions_control_calculate_estimate(uint64_t estimated_execution, uint64_t relative_deadline);
|
||||
uint64_t admissions_control_calculate_estimate_us(uint32_t estimated_execution_us, uint32_t relative_deadline_us);
|
||||
void admissions_control_log_decision(uint64_t admissions_estimate, bool admitted);
|
||||
uint64_t admissions_control_decide(uint64_t admissions_estimate);
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "perf_window_t.h"
|
||||
|
||||
struct admissions_info {
|
||||
struct perf_window perf_window;
|
||||
uint8_t percentile; /* 50 - 99 */
|
||||
int control_index; /* Precomputed Lookup index when perf_window is full */
|
||||
uint64_t estimate; /* cycles */
|
||||
uint64_t relative_deadline; /* Relative deadline in cycles. This is duplicated state */
|
||||
};
|
||||
|
||||
void admissions_info_initialize(struct admissions_info *admissions_info, uint8_t percentile,
|
||||
uint64_t expected_execution, uint64_t relative_deadline);
|
||||
void admissions_info_update(struct admissions_info *admissions_info, uint64_t execution_duration);
|
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "perf_window_t.h"
|
||||
|
||||
struct execution_histogram {
|
||||
struct perf_window perf_window;
|
||||
uint8_t percentile; /* 50 - 99 */
|
||||
int control_index; /* Precomputed Lookup index when perf_window is full */
|
||||
uint64_t estimated_execution; /* cycles */
|
||||
};
|
||||
|
||||
void execution_histogram_initialize(struct execution_histogram *execution_histogram, uint8_t percentile,
|
||||
uint64_t expected_execution);
|
||||
void execution_histogram_update(struct execution_histogram *execution_histogram, uint64_t execution_duration);
|
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef EXECUTION_REGRESSION
|
||||
|
||||
#include "http_session.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint64_t
|
||||
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->paregression_paramram2};
|
||||
|
||||
/* 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)
|
||||
+ model.bias;
|
||||
|
||||
return prediction;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,22 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "admissions_info.h"
|
||||
#include "module.h"
|
||||
#include "execution_histogram.h"
|
||||
#include "http_route_total.h"
|
||||
#include "module.h"
|
||||
#include "perf_window.h"
|
||||
|
||||
struct regression_model {
|
||||
double bias;
|
||||
double scale;
|
||||
uint32_t num_of_param;
|
||||
double beta1;
|
||||
double beta2;
|
||||
};
|
||||
|
||||
/* Assumption: entrypoint is always _start. This should be enhanced later */
|
||||
struct route {
|
||||
char *route;
|
||||
struct http_route_total metrics;
|
||||
struct module *module;
|
||||
/* HTTP State */
|
||||
uint32_t relative_deadline_us;
|
||||
uint64_t relative_deadline; /* cycles */
|
||||
char *response_content_type;
|
||||
struct admissions_info admissions_info;
|
||||
struct perf_window latency;
|
||||
uint32_t relative_deadline_us;
|
||||
uint64_t relative_deadline; /* cycles */
|
||||
char *response_content_type;
|
||||
struct execution_histogram execution_histogram;
|
||||
struct perf_window latency;
|
||||
struct module *module_proprocess;
|
||||
struct regression_model regr_model;
|
||||
};
|
||||
|
@ -1,56 +0,0 @@
|
||||
#include "admissions_control.h"
|
||||
#include "admissions_info.h"
|
||||
#include "debuglog.h"
|
||||
#include "perf_window.h"
|
||||
|
||||
/**
|
||||
* Initializes perf window
|
||||
* @param admissions_info
|
||||
*/
|
||||
void
|
||||
admissions_info_initialize(struct admissions_info *admissions_info, uint8_t percentile, uint64_t expected_execution,
|
||||
uint64_t relative_deadline)
|
||||
{
|
||||
#ifdef ADMISSIONS_CONTROL
|
||||
assert(relative_deadline > 0);
|
||||
assert(expected_execution > 0);
|
||||
admissions_info->relative_deadline = relative_deadline;
|
||||
admissions_info->estimate = admissions_control_calculate_estimate(expected_execution, relative_deadline);
|
||||
debuglog("Initial Estimate: %lu\n", admissions_info->estimate);
|
||||
assert(admissions_info != NULL);
|
||||
|
||||
perf_window_initialize(&admissions_info->perf_window);
|
||||
|
||||
if (unlikely(percentile < 50 || percentile > 99)) panic("Invalid admissions percentile");
|
||||
admissions_info->percentile = percentile;
|
||||
|
||||
admissions_info->control_index = PERF_WINDOW_CAPACITY * percentile / 100;
|
||||
#ifdef LOG_ADMISSIONS_CONTROL
|
||||
debuglog("Percentile: %u\n", admissions_info->percentile);
|
||||
debuglog("Control Index: %d\n", admissions_info->control_index);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Adds an execution value to the perf window and calculates and caches and updated estimate
|
||||
* @param admissions_info
|
||||
* @param execution_duration
|
||||
*/
|
||||
void
|
||||
admissions_info_update(struct admissions_info *admissions_info, uint64_t execution_duration)
|
||||
{
|
||||
#ifdef ADMISSIONS_CONTROL
|
||||
struct perf_window *perf_window = &admissions_info->perf_window;
|
||||
|
||||
lock_node_t node = {};
|
||||
lock_lock(&perf_window->lock, &node);
|
||||
perf_window_add(perf_window, execution_duration);
|
||||
uint64_t estimated_execution = perf_window_get_percentile(perf_window, admissions_info->percentile,
|
||||
admissions_info->control_index);
|
||||
admissions_info->estimate = admissions_control_calculate_estimate(estimated_execution,
|
||||
admissions_info->relative_deadline);
|
||||
lock_unlock(&perf_window->lock, &node);
|
||||
#endif
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
#ifdef EXECUTION_HISTOGRAM
|
||||
|
||||
#include "execution_histogram.h"
|
||||
#include "debuglog.h"
|
||||
#include "perf_window.h"
|
||||
|
||||
/**
|
||||
* Initializes execution_histogram and its perf window
|
||||
* @param execution_histogram
|
||||
*/
|
||||
void
|
||||
execution_histogram_initialize(struct execution_histogram *execution_histogram, uint8_t percentile,
|
||||
uint64_t expected_execution)
|
||||
{
|
||||
assert(expected_execution > 0);
|
||||
execution_histogram->estimated_execution = expected_execution;
|
||||
|
||||
assert(execution_histogram != NULL);
|
||||
perf_window_initialize(&execution_histogram->perf_window);
|
||||
|
||||
if (unlikely(percentile < 50 || percentile > 99)) panic("Invalid percentile");
|
||||
execution_histogram->percentile = percentile;
|
||||
execution_histogram->control_index = PERF_WINDOW_CAPACITY * percentile / 100;
|
||||
#ifdef LOG_EXECUTION_HISTOGRAM
|
||||
debuglog("Percentile: %u\n", execution_histogram->percentile);
|
||||
debuglog("Control Index: %d\n", execution_histogram->control_index);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Adds an execution value to the perf window
|
||||
* @param execution_histogram
|
||||
* @param execution_duration
|
||||
*/
|
||||
void
|
||||
execution_histogram_update(struct execution_histogram *execution_histogram, uint64_t execution_duration)
|
||||
{
|
||||
struct perf_window *perf_window = &execution_histogram->perf_window;
|
||||
|
||||
lock_node_t node = {};
|
||||
lock_lock(&perf_window->lock, &node);
|
||||
perf_window_add(perf_window, execution_duration);
|
||||
uint64_t estimated_execution = perf_window_get_percentile(perf_window, execution_histogram->percentile,
|
||||
execution_histogram->control_index);
|
||||
execution_histogram->estimated_execution = estimated_execution;
|
||||
lock_unlock(&perf_window->lock, &node);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,44 +1,19 @@
|
||||
[
|
||||
{
|
||||
"name": "Admin",
|
||||
"port": 55555,
|
||||
"replenishment-period-us": 0,
|
||||
"max-budget-us": 0,
|
||||
"reservation-percentile": 0,
|
||||
"routes": [
|
||||
{
|
||||
"route": "/admin",
|
||||
"path": "fibonacci.wasm.so",
|
||||
"admissions-percentile": 50,
|
||||
"expected-execution-us": 1000,
|
||||
"relative-deadline-us": 10000,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"route": "/terminator",
|
||||
"path": "fibonacci.wasm.so",
|
||||
"admissions-percentile": 50,
|
||||
"expected-execution-us": 1000,
|
||||
"relative-deadline-us": 10000,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "cmu-000",
|
||||
"port": 10000,
|
||||
"replenishment-period-us": 0,
|
||||
"max-budget-us": 0,
|
||||
"reservation-percentile": 0,
|
||||
"routes": [
|
||||
{
|
||||
"route": "/depth_to_xyz",
|
||||
"path": "depth_to_xyz.wasm.so",
|
||||
"admissions-percentile": 60,
|
||||
"expected-execution-us": 950000,
|
||||
"relative-deadline-us": 4750000,
|
||||
"relative-deadline-us": 0,
|
||||
"http-resp-content-type": "image/png"
|
||||
}
|
||||
]
|
||||
],
|
||||
"replenishment-period-us": 0,
|
||||
"max-budget-us": 0,
|
||||
"reservation-percentile": 0
|
||||
}
|
||||
]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue