|
|
@ -1,14 +1,18 @@
|
|
|
|
#include "admissions_info.h"
|
|
|
|
#include "admissions_info.h"
|
|
|
|
|
|
|
|
#include "perf_window.h"
|
|
|
|
#include "debuglog.h"
|
|
|
|
#include "debuglog.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern __thread uint64_t generic_thread_lock_duration;
|
|
|
|
|
|
|
|
extern __thread uint64_t generic_thread_lock_longest;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initializes perf window
|
|
|
|
* Initializes perf window
|
|
|
|
* @param self
|
|
|
|
* @param self
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
void
|
|
|
|
admissions_info_initialize(struct admissions_info *self, int percentile, uint64_t expected_execution,
|
|
|
|
admissions_info_initialize(struct admissions_info *self, char* module_name, int percentile, uint64_t expected_execution,
|
|
|
|
uint64_t relative_deadline)
|
|
|
|
uint64_t relative_deadline)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
perf_window_initialize(&self->perf_window, module_name);
|
|
|
|
#ifdef ADMISSIONS_CONTROL
|
|
|
|
#ifdef ADMISSIONS_CONTROL
|
|
|
|
assert(relative_deadline > 0);
|
|
|
|
assert(relative_deadline > 0);
|
|
|
|
assert(expected_execution > 0);
|
|
|
|
assert(expected_execution > 0);
|
|
|
@ -17,8 +21,6 @@ admissions_info_initialize(struct admissions_info *self, int percentile, uint64_
|
|
|
|
debuglog("Initial Estimate: %lu\n", self->estimate);
|
|
|
|
debuglog("Initial Estimate: %lu\n", self->estimate);
|
|
|
|
assert(self != NULL);
|
|
|
|
assert(self != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
perf_window_initialize(&self->perf_window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(percentile < 50 || percentile > 99)) panic("Invalid admissions percentile");
|
|
|
|
if (unlikely(percentile < 50 || percentile > 99)) panic("Invalid admissions percentile");
|
|
|
|
self->percentile = percentile;
|
|
|
|
self->percentile = percentile;
|
|
|
|
|
|
|
|
|
|
|
@ -39,13 +41,13 @@ admissions_info_initialize(struct admissions_info *self, int percentile, uint64_
|
|
|
|
void
|
|
|
|
void
|
|
|
|
admissions_info_update(struct admissions_info *self, uint64_t execution_duration)
|
|
|
|
admissions_info_update(struct admissions_info *self, uint64_t execution_duration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef ADMISSIONS_CONTROL
|
|
|
|
|
|
|
|
struct perf_window *perf_window = &self->perf_window;
|
|
|
|
struct perf_window *perf_window = &self->perf_window;
|
|
|
|
|
|
|
|
|
|
|
|
LOCK_LOCK(&self->perf_window.lock);
|
|
|
|
LOCK_LOCK(&self->perf_window.lock);
|
|
|
|
perf_window_add(perf_window, execution_duration);
|
|
|
|
perf_window_add(perf_window, execution_duration);
|
|
|
|
|
|
|
|
#ifdef ADMISSIONS_CONTROL
|
|
|
|
uint64_t estimated_execution = perf_window_get_percentile(perf_window, self->percentile, self->control_index);
|
|
|
|
uint64_t estimated_execution = perf_window_get_percentile(perf_window, self->percentile, self->control_index);
|
|
|
|
self->estimate = admissions_control_calculate_estimate(estimated_execution, self->relative_deadline);
|
|
|
|
self->estimate = admissions_control_calculate_estimate(estimated_execution, self->relative_deadline);
|
|
|
|
LOCK_UNLOCK(&self->perf_window.lock);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
LOCK_UNLOCK(&self->perf_window.lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|