添加线性拟合计算剩余时间,并设置model_base,当预估时间超过base时间的1.2倍,改为base时间

newsch
hwwang 4 weeks ago
parent 10d9659172
commit a696655ad5

@ -112,7 +112,8 @@
"condition_variable": "c", "condition_variable": "c",
"ostream": "c", "ostream": "c",
"stop_token": "c", "stop_token": "c",
"dag_data_split.h": "c" "dag_data_split.h": "c",
"scheduler.h": "c"
}, },
"files.exclude": { "files.exclude": {
"**/.git": true, "**/.git": true,

@ -0,0 +1,46 @@
Summary:
Total: 30.0061 secs
Slowest: 0.1721 secs
Fastest: 0.0035 secs
Average: 0.0088 secs
Requests/sec: 227.3541
Total data: 327456 bytes
Size/request: 48 bytes
Response time histogram:
0.004 [1] |
0.020 [6695] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.037 [114] |■
0.054 [4] |
0.071 [0] |
0.088 [5] |
0.105 [1] |
0.122 [1] |
0.138 [0] |
0.155 [0] |
0.172 [1] |
Latency distribution:
10% in 0.0059 secs
25% in 0.0068 secs
50% in 0.0079 secs
75% in 0.0095 secs
90% in 0.0119 secs
95% in 0.0143 secs
99% in 0.0237 secs
Details (average, fastest, slowest):
DNS+dialup: 0.0004 secs, 0.0035 secs, 0.1721 secs
DNS-lookup: 0.0000 secs, 0.0000 secs, 0.0000 secs
req write: 0.0001 secs, 0.0000 secs, 0.0067 secs
resp wait: 0.0081 secs, 0.0031 secs, 0.1715 secs
resp read: 0.0002 secs, 0.0000 secs, 0.0049 secs
Status code distribution:
[200] 6822 responses

@ -15,4 +15,5 @@ void admissions_info_initialize(struct admissions_info *self, char* module_name,
void admissions_info_update(struct admissions_info *self, uint64_t execution_duration); void admissions_info_update(struct admissions_info *self, uint64_t execution_duration);
uint64_t admission_info_get_percentile(struct admissions_info *self); uint64_t admission_info_get_percentile(struct admissions_info *self);
uint64_t admission_info_get_average(struct admissions_info *self);

@ -83,8 +83,8 @@ struct module {
char **next_module_names; /* the next modules name in the DAG */ char **next_module_names; /* the next modules name in the DAG */
uint32_t next_module_count; uint32_t next_module_count;
uint32_t pre_module_count; uint32_t pre_module_count;
bool runtime_visited; bool runtime_visited; /* used for calculating the estimated time */
uint32_t run_priority; uint32_t run_priority;/* Used for prioritizing data fan-in to a node */
}; };
/************************* /*************************

@ -24,6 +24,7 @@ perf_window_initialize(struct perf_window *self, char* module_name)
self->count = 0; self->count = 0;
memset(&self->by_duration, 0, sizeof(struct execution_node) * PERF_WINDOW_BUFFER_SIZE); memset(&self->by_duration, 0, sizeof(struct execution_node) * PERF_WINDOW_BUFFER_SIZE);
memset(&self->by_termination, 0, sizeof(uint16_t) * PERF_WINDOW_BUFFER_SIZE); memset(&self->by_termination, 0, sizeof(uint16_t) * PERF_WINDOW_BUFFER_SIZE);
memset(&self->by_duration_for_mdl, 0, sizeof(uint64_t) * PERF_WINDOW_BUFFER_SIZE);
} }
@ -90,12 +91,14 @@ perf_window_add(struct perf_window *self, uint64_t value)
self->by_termination[i] = i; self->by_termination[i] = i;
self->by_duration[i] = (struct execution_node){ .execution_time = value, self->by_duration[i] = (struct execution_node){ .execution_time = value,
.by_termination_idx = i }; .by_termination_idx = i };
self->by_duration_for_mdl[i] = value;
} }
self->count = PERF_WINDOW_BUFFER_SIZE; self->count = PERF_WINDOW_BUFFER_SIZE;
goto done; goto done;
} }
/* Otherwise, replace the oldest value, and then sort */ /* Otherwise, replace the oldest value, and then sort */
self->by_duration_for_mdl[self->count % PERF_WINDOW_BUFFER_SIZE] = value;
uint16_t idx_of_oldest = self->by_termination[self->count % PERF_WINDOW_BUFFER_SIZE]; uint16_t idx_of_oldest = self->by_termination[self->count % PERF_WINDOW_BUFFER_SIZE];
bool check_up = value > self->by_duration[idx_of_oldest].execution_time; bool check_up = value > self->by_duration[idx_of_oldest].execution_time;
@ -154,6 +157,31 @@ perf_window_get_percentile(struct perf_window *self, int percentile, int precomp
return self->by_duration[size * percentile / 100].execution_time; return self->by_duration[size * percentile / 100].execution_time;
} }
static inline uint64_t
perf_window_get_average(struct perf_window *self)
{
assert(self != NULL);
int size = self->count;
if (size == 0) {
return 0;
} else if (size < PERF_WINDOW_BUFFER_SIZE) {
uint64_t average = 0;
for (size_t i = 0; i < size; i++)
{
average += self->by_duration_for_mdl[i];
}
average = average / size;
return average;
} else{
uint64_t average = 0;
for (size_t i = 0; i < PERF_WINDOW_BUFFER_SIZE; i++) {
average += self->by_duration_for_mdl[i];
}
average /= PERF_WINDOW_BUFFER_SIZE;
return average;
}
}
/** /**
* Returns the total count of executions * Returns the total count of executions
* @returns total count * @returns total count

@ -26,6 +26,7 @@ struct execution_node {
struct perf_window { struct perf_window {
char name[32]; char name[32];
struct execution_node by_duration[PERF_WINDOW_BUFFER_SIZE]; struct execution_node by_duration[PERF_WINDOW_BUFFER_SIZE];
uint64_t by_duration_for_mdl[PERF_WINDOW_BUFFER_SIZE];
uint16_t by_termination[PERF_WINDOW_BUFFER_SIZE]; uint16_t by_termination[PERF_WINDOW_BUFFER_SIZE];
uint64_t count; uint64_t count;
lock_t lock; lock_t lock;

@ -119,8 +119,9 @@ static inline uint64_t
sandbox_get_mdl_priority(void *element) sandbox_get_mdl_priority(void *element)
{ {
struct sandbox *sandbox = (struct sandbox *)element; struct sandbox *sandbox = (struct sandbox *)element;
//uint64_t now = __getcycles(); uint64_t now = __getcycles();
return sandbox->absolute_deadline; uint64_t remaining_slack_mdl = sandbox->remaining_slack - (now - sandbox->last_update_timestamp);
return remaining_slack_mdl;
}; };
/** /**

@ -119,7 +119,7 @@ scheduler_MDL_get_next()
{ {
/* Get the deadline of the sandbox at the head of the local request queue */ /* Get the deadline of the sandbox at the head of the local request queue */
struct sandbox * local = local_runqueue_get_next(); struct sandbox * local = local_runqueue_get_next();
uint64_t local_remaining_MDL = local == NULL ? UINT64_MAX : local->absolute_deadline; uint64_t local_remaining_MDL = local == NULL ? UINT64_MAX : local->remaining_slack;
struct sandbox_request *request = NULL; struct sandbox_request *request = NULL;
uint64_t global_remaining_slack = global_request_scheduler_peek(); uint64_t global_remaining_slack = global_request_scheduler_peek();

@ -42,6 +42,19 @@ admission_info_get_percentile(struct admissions_info *self)
uint64_t estimated_execution = perf_window_get_percentile(&self->perf_window, self->percentile, self->control_index); uint64_t estimated_execution = perf_window_get_percentile(&self->perf_window, self->percentile, self->control_index);
return estimated_execution; return estimated_execution;
} }
/*
* Get the average execution time of this module, no lock for accessing the queue
* @param self
* @returns the specified execution time of this module
*/
uint64_t
admission_info_get_average(struct admissions_info *self)
{
uint64_t estimated_execution = perf_window_get_average(&self->perf_window);
return estimated_execution;
}
/* /*
* Adds an execution value to the perf window and calculates and caches and updated estimate * Adds an execution value to the perf window and calculates and caches and updated estimate
* @param self * @param self

@ -84,8 +84,9 @@ uint64_t
sandbox_request_get_priority_mdl_fn(void *element) sandbox_request_get_priority_mdl_fn(void *element)
{ {
struct sandbox_request *sandbox_request = (struct sandbox_request *)element; struct sandbox_request *sandbox_request = (struct sandbox_request *)element;
//uint64_t now = __getcycles(); uint64_t now = __getcycles();
return sandbox_request->absolute_deadline; uint64_t remaining_slack_mdl = sandbox_request->remaining_slack - (now - sandbox_request->last_update_timestamp);
return remaining_slack_mdl;
}; };
/** /**

@ -7,8 +7,10 @@
#include "generic_thread.h" #include "generic_thread.h"
#include "listener_thread.h" #include "listener_thread.h"
#include "runtime.h" #include "runtime.h"
#include "scheduler.h"
extern uint64_t system_start_timestamp; extern uint64_t system_start_timestamp;
extern enum SCHEDULER scheduler;
/*When reading the json file, the size has been determined at module.c JSON_MAX_ELEMENT_COUNT*/ /*When reading the json file, the size has been determined at module.c JSON_MAX_ELEMENT_COUNT*/
const int QUEUE_SIZE = 16; const int QUEUE_SIZE = 16;
/* /*
@ -185,7 +187,20 @@ listener_thread_main(void *dummy)
while (rear != front) while (rear != front)
{ {
struct module *current_module = queue[front++]; struct module *current_module = queue[front++];
estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info); if (scheduler == SCHEDULER_SRSF || scheduler == SCHEDULER_EDF)
{
estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info);
}else if (scheduler == SCHEDULER_MDL){
/* Set a baseline model, and if the predicted parameters of the model are more than 1.2 times the parameters of the baseline, then select the baseline parameters */
uint64_t estimated_execution_base_percentile = 0, estimated_execution_model = 0;
estimated_execution_base_percentile = admission_info_get_percentile(&current_module->admissions_info);
estimated_execution_model = admission_info_get_average(&current_module->admissions_info);
if (estimated_execution_model > 1.2 * estimated_execution_base_percentile)
{
estimated_execution_model = estimated_execution_base_percentile;
}
estimated_execution_time += estimated_execution_model;
}
for (int i = 0; i < current_module->next_module_count; i++) { for (int i = 0; i < current_module->next_module_count; i++) {
if (current_module->next_module[i] != NULL && !current_module->next_module[i]->runtime_visited) if (current_module->next_module[i] != NULL && !current_module->next_module[i]->runtime_visited)
{ {

@ -95,10 +95,10 @@ sigalrm_propagate_workers(siginfo_t *signal_info)
if (global_slack < local_remaining_slack) pthread_kill(runtime_worker_threads[i], SIGALRM); if (global_slack < local_remaining_slack) pthread_kill(runtime_worker_threads[i], SIGALRM);
continue; continue;
} else if (scheduler == SCHEDULER_MDL) { } else if (scheduler == SCHEDULER_MDL) {
uint64_t local_deadline = runtime_worker_threads_deadline[i]; uint64_t local_remaining_slack = runtime_worker_threads_remaining_slack[i];
uint64_t global_deadline = global_request_scheduler_peek(); uint64_t global_slack = global_request_scheduler_peek();
if (global_deadline < local_deadline) pthread_kill(runtime_worker_threads[i], SIGALRM); if (global_slack < local_remaining_slack) pthread_kill(runtime_worker_threads[i], SIGALRM);
continue; continue;
} }
} }
case RUNTIME_SIGALRM_HANDLER_BROADCAST: { case RUNTIME_SIGALRM_HANDLER_BROADCAST: {

File diff suppressed because one or more lines are too long

@ -30,8 +30,8 @@ export SLEDGE_SANDBOX_PERF_LOG=$path/$output
echo $SLEDGE_SANDBOX_PERF_LOG echo $SLEDGE_SANDBOX_PERF_LOG
cd $project_path/runtime/bin cd $project_path/runtime/bin
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/graph.json #LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/graph.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing_graph.json LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing_graph.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_dag_image.json #LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_dag_image.json

Loading…
Cancel
Save