Compare commits
8 Commits
master
...
worker_gen
Author | SHA1 | Date |
---|---|---|
|
8164b5274f | 3 years ago |
|
c205066070 | 3 years ago |
|
0d46f8a068 | 3 years ago |
|
49f5ba3897 | 3 years ago |
|
6e3d6ef311 | 3 years ago |
|
5ac779f5c4 | 3 years ago |
|
33fecdb247 | 3 years ago |
|
9073972ba6 | 3 years ago |
@ -1,23 +1,24 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"includePath": [
|
||||
"/usr/include/",
|
||||
"${workspaceFolder}/runtime/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/ck/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/http-parser/",
|
||||
"${workspaceFolder}/runtime/thirdparty/jsmn/",
|
||||
"${workspaceFolder}/awsm/runtime/libc/wasi/include/",
|
||||
"${workspaceFolder}/libsledge/include"
|
||||
],
|
||||
"defines": [
|
||||
"x86_64",
|
||||
"_GNU_SOURCE"
|
||||
],
|
||||
"cStandard": "c17"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"includePath": [
|
||||
"/usr/include/",
|
||||
"${workspaceFolder}/runtime/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/ck/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/http-parser/",
|
||||
"${workspaceFolder}/runtime/thirdparty/jsmn/",
|
||||
"${workspaceFolder}/awsm/runtime/libc/wasi/include/",
|
||||
"${workspaceFolder}/libsledge/include"
|
||||
],
|
||||
"defines": [
|
||||
"x86_64",
|
||||
"_GNU_SOURCE"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"compilerPath": "/usr/bin/clang"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 272fcf42b6559ccb5c5213eb78edfc0f703520ab
|
||||
Subproject commit 69c8b6116664d65a851cc459601bef6af3caeaea
|
@ -1,19 +1,18 @@
|
||||
#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
|
@ -0,0 +1,15 @@
|
||||
#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);
|
@ -1,14 +0,0 @@
|
||||
#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);
|
@ -1,26 +0,0 @@
|
||||
#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->regression_param};
|
||||
|
||||
/* 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,32 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "execution_histogram.h"
|
||||
#include "http_route_total.h"
|
||||
#include "admissions_info.h"
|
||||
#include "module.h"
|
||||
#include "http_route_total.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 execution_histogram execution_histogram;
|
||||
struct perf_window latency;
|
||||
struct module *module_proprocess;
|
||||
struct regression_model regr_model;
|
||||
uint32_t relative_deadline_us;
|
||||
uint64_t relative_deadline; /* cycles */
|
||||
char *response_content_type;
|
||||
struct admissions_info admissions_info;
|
||||
struct perf_window latency;
|
||||
};
|
||||
|
@ -0,0 +1,56 @@
|
||||
#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
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
#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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue