添加机器学习框架数据获取代码,主要是获取TCP套接字报文大小

sledge_graph
hwwang 2 weeks ago
parent 87672b74c4
commit 8990f5c5ed

@ -1,3 +1,3 @@
LD_LIBRARY_PATH=/home/weihao/sledge/sledge_tree/runtime/bin LD_LIBRARY_PATH=/home/hai/sledge/sledge/runtime/bin
SLEDGE_SCHEDULER=EDF SLEDGE_SCHEDULER=MDL
SLEDGE_SANDBOX_PERF_LOG=/home/weihao/sledge/sledge_tree/runtime_sandbox_perf_log.log SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge/sledge/runtime/tests/runtime_sandbox_perf_log.log

6
.gitignore vendored

@ -58,9 +58,9 @@ runtime/tests/**/*.txt
runtime/tests/**/*.xlsx runtime/tests/**/*.xlsx
runtime/tests/test_data runtime/tests/test_data
runtime/tests/*.log runtime/tests/*.log
data/*.txt runtime/data/*.txt
data/*.log runtime/data/*.log
data/*.json runtime/data/*.json
# Swap Files # Swap Files
*.swp *.swp

@ -10,7 +10,8 @@
"USE_MEM_VM", "USE_MEM_VM",
"x86_64", "x86_64",
"_GNU_SOURCE", "_GNU_SOURCE",
"LOG_TO_FILE" "LOG_TO_FILE",
"DEEP_LEARN_SCHDUE"
], ],
"cStandard": "${default}", "cStandard": "${default}",
"compilerPath": "/usr/bin/clang", "compilerPath": "/usr/bin/clang",

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

@ -41,6 +41,14 @@ BINARY_NAME=sledgert
# Feature Toggles # Feature Toggles
# CFLAGS += -DADMISSIONS_CONTROL # CFLAGS += -DADMISSIONS_CONTROL
# This definition is used when the module is triggered by an HTTP request.
# It retrieves the length of the HTTP message data, the hash table, and the global queue length via a TCP socket.
# These values are then used as features for machine learning training
# CFLAGS += -DDEEP_LEARN_SCHDUE
# This definition determines whether to use the median or the mean to calculate the execution times of the first 256 services.
# CFLAGS += -DGET_AVER_TIME
# Debugging Flags # Debugging Flags
# Strips out calls to assert() and disables debuglog # Strips out calls to assert() and disables debuglog
@ -59,8 +67,11 @@ CFLAGS += -DLOG_TO_FILE
# CFLAGS += -DLOG_PREEMPTION # CFLAGS += -DLOG_PREEMPTION
# CFLAGS += -DLOG_MODULE_LOADING # CFLAGS += -DLOG_MODULE_LOADING
# CFLAGS += -DOPT_AVOID_GLOBAL_QUEUE # CFLAGS += -DOPT_AVOID_GLOBAL_QUEUE
CFLAGS += -DLOG_RUNTIME_FILE_LOG # CFLAGS += -DLOG_RUNTIME_FILE_LOG
#CFLAGS += -DLOG_RUNTIME_MEM_LOG CFLAGS += -DLOG_RUNTIME_MEM_LOG
# For machine learning purposes, the following data is collected and saved:
# Length of the HTTP message Hash table Global queue length Service execution time
# CFLAGS += -DLOG_DEEP_LEARN_SCHDUE
# This dumps per module *.csv files containing the cycle a sandbox has been in RUNNING when each # This dumps per module *.csv files containing the cycle a sandbox has been in RUNNING when each
# page is allocated. This helps understand the relationship to memory allocation and execution time. # page is allocated. This helps understand the relationship to memory allocation and execution time.

@ -0,0 +1,51 @@
import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
def load_data(filename):
"""
Load data from a file.
Assumes that each line in the file is a float value.
"""
with open(filename, 'r') as file:
data = file.read().split()
data = [float(i) for i in data]
return data
def main():
# 加载数据
edf_data = load_data('edf_5k.txt')
llf_data = load_data('llf_5k.txt')
# 设置X轴的数据点
x_labels = [50, 60, 70, 80, 90, 100] # 确保数据与这些标签相匹配
font_properties = fm.FontProperties(family='Times New Roman', size=18)
plt.rcParams.update({'font.size': 18, 'font.family': 'Times New Roman'})
# 创建图形和绘制数据
plt.figure(figsize=(10, 6))
ax = plt.gca() # 获取当前的Axes对象ax
ax.set_facecolor('#f0f0f0') # 设置浅灰色背景
plt.plot(x_labels, edf_data, marker='s', linestyle='-', color='#C8503D', markersize=8, label='EDF')
plt.plot(x_labels, llf_data, marker='^', linestyle='-', color='#00008B', markersize=8, label='LLF')
# 添加标题、标签和图例
plt.title('5KB-1.2* Deadline', fontsize=20, fontproperties=font_properties)
plt.xlabel('Load (% of maximum RPS)', fontproperties=font_properties)
plt.ylabel('Deadline Miss Rate (%)', fontproperties=font_properties)
plt.legend(prop=font_properties)
# 设置X轴刻度
plt.xticks(range(50, 101, 10))
# 设置网格
plt.grid(True)
# 移除边框的四边刻度线
plt.tick_params(axis='both', which='both', length=0) # 移除刻度线
# 显示图形
plt.show()
if __name__ == "__main__":
main()

@ -9,12 +9,14 @@ typedef struct sandbox_request *(*global_request_scheduler_add_fn_t)(void *);
typedef int (*global_request_scheduler_remove_fn_t)(struct sandbox_request **); typedef int (*global_request_scheduler_remove_fn_t)(struct sandbox_request **);
typedef int (*global_request_scheduler_remove_if_earlier_fn_t)(struct sandbox_request **, uint64_t); typedef int (*global_request_scheduler_remove_if_earlier_fn_t)(struct sandbox_request **, uint64_t);
typedef uint64_t (*global_request_scheduler_peek_fn_t)(void); typedef uint64_t (*global_request_scheduler_peek_fn_t)(void);
typedef int (*global_request_scheduler_size_fn_t)(void);
struct global_request_scheduler_config { struct global_request_scheduler_config {
global_request_scheduler_add_fn_t add_fn; global_request_scheduler_add_fn_t add_fn;
global_request_scheduler_remove_fn_t remove_fn; global_request_scheduler_remove_fn_t remove_fn;
global_request_scheduler_remove_if_earlier_fn_t remove_if_earlier_fn; global_request_scheduler_remove_if_earlier_fn_t remove_if_earlier_fn;
global_request_scheduler_peek_fn_t peek_fn; global_request_scheduler_peek_fn_t peek_fn;
global_request_scheduler_size_fn_t size_fn;
}; };
@ -23,3 +25,4 @@ struct sandbox_request *global_request_scheduler_add(struct sandbox_request *);
int global_request_scheduler_remove(struct sandbox_request **); int global_request_scheduler_remove(struct sandbox_request **);
int global_request_scheduler_remove_if_earlier(struct sandbox_request **, uint64_t targed_deadline); int global_request_scheduler_remove_if_earlier(struct sandbox_request **, uint64_t targed_deadline);
uint64_t global_request_scheduler_peek(void); uint64_t global_request_scheduler_peek(void);
int global_request_scheduler_size(void);

@ -39,7 +39,14 @@
#warning \ #warning \
"MODULE_MAX_PENDING_CLIENT_REQUESTS likely exceeds the value in /proc/sys/net/core/somaxconn and thus may be silently truncated"; "MODULE_MAX_PENDING_CLIENT_REQUESTS likely exceeds the value in /proc/sys/net/core/somaxconn and thus may be silently truncated";
#endif #endif
#ifdef DEEP_LEARN_SCHDUE
struct MDL
{
int hash_node;
int global_queue_node;
int http_data_size;
};
#endif
struct module { struct module {
char name[MODULE_MAX_NAME_LENGTH]; char name[MODULE_MAX_NAME_LENGTH];
char path[MODULE_MAX_PATH_LENGTH]; char path[MODULE_MAX_PATH_LENGTH];
@ -85,6 +92,9 @@ struct module {
uint32_t pre_module_count; uint32_t pre_module_count;
bool runtime_visited; /* used for calculating the estimated time */ bool runtime_visited; /* used for calculating the estimated time */
uint32_t run_priority;/* Used for prioritizing data fan-in to a node */ uint32_t run_priority;/* Used for prioritizing data fan-in to a node */
#ifdef DEEP_LEARN_SCHDUE
struct MDL mdl;/*save data for deep learn */
#endif
}; };
/************************* /*************************

@ -24,7 +24,9 @@ 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);
#ifdef GET_AVER_TIME
memset(&self->by_duration_for_mdl, 0, sizeof(uint64_t) * PERF_WINDOW_BUFFER_SIZE); memset(&self->by_duration_for_mdl, 0, sizeof(uint64_t) * PERF_WINDOW_BUFFER_SIZE);
#endif
} }
@ -91,14 +93,18 @@ 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 };
#ifdef GET_AVER_TIME
self->by_duration_for_mdl[i] = value; self->by_duration_for_mdl[i] = value;
#endif
} }
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 */
#ifdef GET_AVER_TIME
self->by_duration_for_mdl[self->count % PERF_WINDOW_BUFFER_SIZE] = value; self->by_duration_for_mdl[self->count % PERF_WINDOW_BUFFER_SIZE] = value;
#endif
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;
@ -157,6 +163,7 @@ 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;
} }
#ifdef GET_AVER_TIME
static inline uint64_t static inline uint64_t
perf_window_get_average(struct perf_window *self) perf_window_get_average(struct perf_window *self)
{ {
@ -181,6 +188,7 @@ perf_window_get_average(struct perf_window *self)
return average; return average;
} }
} }
#endif
/** /**
* Returns the total count of executions * Returns the total count of executions

@ -26,7 +26,9 @@ 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];
#ifdef GET_AVER_TIME
uint64_t by_duration_for_mdl[PERF_WINDOW_BUFFER_SIZE]; uint64_t by_duration_for_mdl[PERF_WINDOW_BUFFER_SIZE];
#endif
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;

@ -298,7 +298,9 @@ static inline int
priority_queue_length_nolock(struct priority_queue *self) priority_queue_length_nolock(struct priority_queue *self)
{ {
assert(self != NULL); assert(self != NULL);
#ifndef DEEP_LEARN_SCHDUE
assert(!listener_thread_is_running()); assert(!listener_thread_is_running());
#endif
assert(!self->use_lock || LOCK_IS_LOCKED(&self->lock)); assert(!self->use_lock || LOCK_IS_LOCKED(&self->lock));
return self->size; return self->size;

@ -266,3 +266,20 @@ sandbox_mem_print_perf(struct sandbox *sandbox)
running_us, blocked_us, returned_us, sandbox->linear_memory_size); running_us, blocked_us, returned_us, sandbox->linear_memory_size);
} }
static inline void
sandbox_MDL_print_perf(struct sandbox *sandbox)
{
#ifndef LOG_DEEP_LEARN_SCHDUE
return;
#endif
/* If the log was not defined by an environment variable, early out */
if (runtime_sandbox_perf_log == NULL) return;
#ifdef DEEP_LEARN_SCHDUE
if (sandbox->module->next_module == NULL) {
uint64_t total_time = (sandbox->completion_timestamp - sandbox->request_arrival_timestamp) / runtime_processor_speed_MHz;
fprintf(runtime_sandbox_perf_log, "%s,%lu,%d,%d,%d\n", sandbox->module->name, total_time,sandbox->module->mdl.hash_node,sandbox->module->mdl.global_queue_node,sandbox->module->mdl.http_data_size);
}
#endif
}

@ -59,6 +59,9 @@ sandbox_set_as_complete(struct sandbox *sandbox, sandbox_state_t last_state)
/* Terminal State Logging */ /* Terminal State Logging */
sandbox_print_perf(sandbox); sandbox_print_perf(sandbox);
sandbox_mem_print_perf(sandbox); sandbox_mem_print_perf(sandbox);
#ifdef DEEP_LEARN_SCHDUE
sandbox_MDL_print_perf(sandbox);
#endif
sandbox_summarize_page_allocations(sandbox); sandbox_summarize_page_allocations(sandbox);
/* Do not touch sandbox state after adding to completion queue to avoid use-after-free bugs */ /* Do not touch sandbox state after adding to completion queue to avoid use-after-free bugs */

@ -54,6 +54,9 @@ sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state)
sandbox->state = SANDBOX_ERROR; sandbox->state = SANDBOX_ERROR;
sandbox_print_perf(sandbox); sandbox_print_perf(sandbox);
sandbox_mem_print_perf(sandbox); sandbox_mem_print_perf(sandbox);
#ifdef DEEP_LEARN_SCHDUE
sandbox_MDL_print_perf(sandbox);
#endif
sandbox_summarize_page_allocations(sandbox); sandbox_summarize_page_allocations(sandbox);
sandbox_free_linear_memory(sandbox); sandbox_free_linear_memory(sandbox);
admissions_control_subtract(sandbox->admissions_estimate); admissions_control_subtract(sandbox->admissions_estimate);

@ -43,6 +43,7 @@ admission_info_get_percentile(struct admissions_info *self)
return estimated_execution; return estimated_execution;
} }
#ifdef GET_AVER_TIME
/* /*
* Get the average execution time of this module, no lock for accessing the queue * Get the average execution time of this module, no lock for accessing the queue
* @param self * @param self
@ -54,6 +55,7 @@ admission_info_get_average(struct admissions_info *self)
uint64_t estimated_execution = perf_window_get_average(&self->perf_window); uint64_t estimated_execution = perf_window_get_average(&self->perf_window);
return estimated_execution; return estimated_execution;
} }
#endif
/* /*
* 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

@ -13,6 +13,13 @@
extern uint64_t system_start_timestamp; extern uint64_t system_start_timestamp;
lock_t lock; lock_t lock;
#ifdef DEEP_LEARN_SCHDUE
_Atomic uint32_t hash_count = 0;
#endif
#define OUTPUT_BUFER_SIZE 1024*5 #define OUTPUT_BUFER_SIZE 1024*5
__thread struct sandbox *worker_thread_current_sandbox = NULL; __thread struct sandbox *worker_thread_current_sandbox = NULL;
@ -87,6 +94,9 @@ current_sandbox_start(void)
if(sandbox_req_map == NULL) if(sandbox_req_map == NULL)
{ {
sandbox_req_map = malloc(sizeof(struct hashmap)); sandbox_req_map = malloc(sizeof(struct hashmap));
#ifdef DEEP_LEARN_SCHDUE
atomic_init(&hash_count, 0);
#endif
map_init(sandbox_req_map); map_init(sandbox_req_map);
} }
if(sandbox_request_id == NULL) if(sandbox_request_id == NULL)
@ -179,6 +189,17 @@ current_sandbox_start(void)
memcpy(individual_pre_func_output, pre_func_output, output_length); memcpy(individual_pre_func_output, pre_func_output, output_length);
uint64_t now = __getcycles(); uint64_t now = __getcycles();
current_sandbox_get_newlaxity(sandbox, now); current_sandbox_get_newlaxity(sandbox, now);
#ifdef LOG_DEEP_LEARN_SCHDUE
#ifdef DEEP_LEARN_SCHDUE
/*
* If model parameters need to be trained, then enable the feature;
* otherwise, disable it to avoid unnecessary overhead.
*/
next_module_node->mdl.hash_node = sandbox->module->mdl.hash_node;
next_module_node->mdl.global_queue_node = sandbox->module->mdl.global_queue_node;
next_module_node->mdl.http_data_size = sandbox->module->mdl.http_data_size;
#endif
#endif
struct sandbox_request *sandbox_request = struct sandbox_request *sandbox_request =
sandbox_request_allocate(next_module_node, false, sandbox->request_length, sandbox_request_allocate(next_module_node, false, sandbox->request_length,
next_module_node->name, sandbox->client_socket_descriptor, next_module_node->name, sandbox->client_socket_descriptor,
@ -254,6 +275,17 @@ current_sandbox_start(void)
current_sandbox_get_newlaxity(sandbox, now); current_sandbox_get_newlaxity(sandbox, now);
//mem_log("time %lu request id:%d executing, name:%s remaining slack %lu\n", current_rs, //mem_log("time %lu request id:%d executing, name:%s remaining slack %lu\n", current_rs,
// sandbox->id, sandbox->module->name, sandbox->remaining_slack); // sandbox->id, sandbox->module->name, sandbox->remaining_slack);
#ifdef LOG_DEEP_LEARN_SCHDUE
#ifdef DEEP_LEARN_SCHDUE
/*
* If model parameters need to be trained, then enable the feature;
* otherwise, disable it to avoid unnecessary overhead.
*/
next_module_node->mdl.hash_node = sandbox->module->mdl.hash_node;
next_module_node->mdl.global_queue_node = sandbox->module->mdl.global_queue_node;
next_module_node->mdl.http_data_size = sandbox->module->mdl.http_data_size;
#endif
#endif
struct sandbox_request *sandbox_request = struct sandbox_request *sandbox_request =
sandbox_request_allocate(next_module_node, false, sandbox->request_length, sandbox_request_allocate(next_module_node, false, sandbox->request_length,
next_module_node->name, sandbox->client_socket_descriptor, next_module_node->name, sandbox->client_socket_descriptor,
@ -271,6 +303,9 @@ current_sandbox_start(void)
if(!map_set(sandbox_request_id, cur_request_id, strlen(cur_request_id), &module_pre_count, sizeof(uint32_t), true)) panic("the map of sandbox_request_id is NULL\n"); if(!map_set(sandbox_request_id, cur_request_id, strlen(cur_request_id), &module_pre_count, sizeof(uint32_t), true)) panic("the map of sandbox_request_id is NULL\n");
if(!map_set(sandbox_req_map, cur_request_id, strlen(cur_request_id), sandbox_request, sizeof(struct sandbox_request *), false)) panic("the map of sandbox_request is NULL\n"); if(!map_set(sandbox_req_map, cur_request_id, strlen(cur_request_id), sandbox_request, sizeof(struct sandbox_request *), false)) panic("the map of sandbox_request is NULL\n");
mapflag = true; mapflag = true;
#ifdef DEEP_LEARN_SCHDUE
atomic_fetch_add(&hash_count, 1);
#endif
} }
LOCK_UNLOCK(&lock); LOCK_UNLOCK(&lock);
struct sandbox_request *sandbox_request = map_get(sandbox_req_map, cur_request_id, strlen(cur_request_id), &ret_value_len); struct sandbox_request *sandbox_request = map_get(sandbox_req_map, cur_request_id, strlen(cur_request_id), &ret_value_len);
@ -297,6 +332,9 @@ current_sandbox_start(void)
global_request_scheduler_add(sandbox_request); global_request_scheduler_add(sandbox_request);
map_delete(sandbox_req_map, cur_request_id, strlen(cur_request_id)); map_delete(sandbox_req_map, cur_request_id, strlen(cur_request_id));
map_delete(sandbox_request_id, cur_request_id, strlen(cur_request_id)); map_delete(sandbox_request_id, cur_request_id, strlen(cur_request_id));
#ifdef DEEP_LEARN_SCHDUE
atomic_fetch_sub(&hash_count, 1);
#endif
} }
pthread_spin_unlock(&sandbox_request->lock); pthread_spin_unlock(&sandbox_request->lock);
} }

@ -91,3 +91,8 @@ global_request_scheduler_peek()
{ {
return global_request_scheduler.peek_fn(); return global_request_scheduler.peek_fn();
} }
int
global_request_scheduler_size(){
return global_request_scheduler.size_fn();
}

@ -64,6 +64,12 @@ global_request_scheduler_minheap_peek(void)
return priority_queue_peek(global_request_scheduler_minheap); return priority_queue_peek(global_request_scheduler_minheap);
} }
static int
global_request_scheduler_minheap_size(void)
{
return priority_queue_length(global_request_scheduler_minheap);
}
uint64_t uint64_t
sandbox_request_get_priority_fn(void *element) sandbox_request_get_priority_fn(void *element)
{ {
@ -119,7 +125,8 @@ global_request_scheduler_minheap_initialize(enum SCHEDULER scheduler)
.add_fn = global_request_scheduler_minheap_add, .add_fn = global_request_scheduler_minheap_add,
.remove_fn = global_request_scheduler_minheap_remove, .remove_fn = global_request_scheduler_minheap_remove,
.remove_if_earlier_fn = global_request_scheduler_minheap_remove_if_earlier, .remove_if_earlier_fn = global_request_scheduler_minheap_remove_if_earlier,
.peek_fn = global_request_scheduler_minheap_peek .peek_fn = global_request_scheduler_minheap_peek,
.size_fn = global_request_scheduler_minheap_size
}; };
global_request_scheduler_initialize(&config); global_request_scheduler_initialize(&config);

@ -9,10 +9,13 @@
#include "runtime.h" #include "runtime.h"
#include "scheduler.h" #include "scheduler.h"
#ifdef DEEP_LEARN_SCHDUE
extern _Atomic uint32_t hash_count;
#endif
extern uint64_t system_start_timestamp; extern uint64_t system_start_timestamp;
extern enum SCHEDULER scheduler; 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 = 36;
/* /*
* Descriptor of the epoll instance used to monitor the socket descriptors of registered * Descriptor of the epoll instance used to monitor the socket descriptors of registered
* serverless modules. The listener cores listens for incoming client requests through this. * serverless modules. The listener cores listens for incoming client requests through this.
@ -178,6 +181,30 @@ listener_thread_main(void *dummy)
continue; continue;
} }
#ifdef DEEP_LEARN_SCHDUE
/*Get HTTP buffer size*/
int content_length = 0;
module->mdl.global_queue_node = global_request_scheduler_size();
module->mdl.hash_node = hash_count;
char buffer[1024];
ssize_t nbytes_peeked = recv(client_socket, buffer, sizeof(buffer), MSG_PEEK);
if (nbytes_peeked <= 0){
content_length = 5090;
} else{
buffer[sizeof(buffer)-1] = '\0';
const char *content_length_str = "Content-Length: ";
char *start = strstr(buffer, content_length_str);
if (start) {
start += strlen(content_length_str);
while (*start == ' ') start++;
content_length = atoi(start);
//debuglog("Content-Length: %d\n", content_length);
}else{
content_length = 5090;
}
}
module->mdl.http_data_size = content_length;
#endif
/* get total estimated execution time */ /* get total estimated execution time */
uint64_t estimated_execution_time = 0; uint64_t estimated_execution_time = 0;
int front = 0, rear = 0; int front = 0, rear = 0;
@ -190,15 +217,11 @@ listener_thread_main(void *dummy)
{ {
estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info); estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info);
}else if (scheduler == SCHEDULER_MDL ){ }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 */ #ifdef GET_AVER_TIME
uint64_t estimated_execution_base_percentile = 0, estimated_execution_model = 0; estimated_execution_time += admission_info_get_average(&current_module->admissions_info);
estimated_execution_base_percentile = admission_info_get_percentile(&current_module->admissions_info); #else
estimated_execution_model = admission_info_get_average(&current_module->admissions_info); estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info);
if (estimated_execution_model > 1.2 * estimated_execution_base_percentile) #endif
{
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)

@ -231,9 +231,13 @@ runtime_configure()
printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path); printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path);
runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w"); runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w");
if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); } if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); }
#ifdef LOG_DEEP_LEARN_SCHDUE
fprintf(runtime_sandbox_perf_log, "module.name, total_time,module.hash_node,modul.global_queue_node,module.http_data_size\n");
#else
fprintf(runtime_sandbox_perf_log, "threadid,id,function,state,deadline,actual,queued,initializing,runnable," fprintf(runtime_sandbox_perf_log, "threadid,id,function,state,deadline,actual,queued,initializing,runnable,"
"running,blocked,returned,memory\n"); "running,blocked,returned,memory\n");
//fflush(runtime_sandbox_perf_log); #endif
} else { } else {
printf("\tSandbox Performance Log: Disabled\n"); printf("\tSandbox Performance Log: Disabled\n");
} }

@ -19,7 +19,7 @@
const int JSON_MAX_ELEMENT_COUNT = 16; const int JSON_MAX_ELEMENT_COUNT = 16;
const int JSON_MAX_ELEMENT_SIZE = 1024; const int JSON_MAX_ELEMENT_SIZE = 1024;
const int PRE_MODULE_COUNT = 4; const int MODULE_MAX_COUNT = 36;
/************************* /*************************
* Private Static Inline * * Private Static Inline *
@ -375,7 +375,7 @@ module_new_from_json(char *file_name)
int module_count = 0; int module_count = 0;
char *request_headers = NULL; char *request_headers = NULL;
char *reponse_headers = NULL; char *reponse_headers = NULL;
struct module **nodes = malloc(JSON_MAX_ELEMENT_COUNT * sizeof(struct module*)); struct module **nodes = malloc( MODULE_MAX_COUNT * sizeof(struct module*));
if (nodes == NULL) { if (nodes == NULL) {
panic("Memory allocation failed for nodes array\n"); panic("Memory allocation failed for nodes array\n");
} }
@ -622,6 +622,11 @@ module_new_from_json(char *file_name)
module->pre_module = NULL; module->pre_module = NULL;
module->runtime_visited = false; module->runtime_visited = false;
module->run_priority = priority; module->run_priority = priority;
#ifdef DEEP_LEARN_SCHDUE
module->mdl.hash_node = 0;
module->mdl.global_queue_node = 0;
module->mdl.http_data_size = 0;
#endif
assert(module); assert(module);
module_set_http_info(module, request_count, request_headers, request_content_type, module_set_http_info(module, request_count, request_headers, request_content_type,

@ -25,9 +25,9 @@ pid2=$!
pid3=$! pid3=$!
./test_8c.sh $f4 $duration $concurrency 40k.jpg 10009 2>&1 & ./test_8c.sh $f4 $duration $concurrency 40k.jpg 10009 2>&1 &
pid4=$! pid4=$!
wait -f $pid1 wait $pid1
wait -f $pid2 wait $pid2
wait -f $pid3 wait $pid3
wait -f $pid4 wait $pid4
printf "[OK]\n" printf "[OK]\n"

@ -36,7 +36,7 @@ def get_values(key, value, miss_deadline_rate, total_latency, running_times, pre
before_dot = file_name.split(".")[0] before_dot = file_name.split(".")[0]
joint_f_name = before_dot + "_total_time.txt" joint_f_name = before_dot + "_total_time.txt"
cmd='python3 ~/sledge-serverless-framework/runtime/tests/meet_deadline_percentage.py %s 50' % file_name cmd='python3 /home/hai/sledge/sledge/runtime/tests/meet_deadline_percentage.py %s 50' % file_name
rt=os.popen(cmd).read().strip() rt=os.popen(cmd).read().strip()
cmd2='mv total_time.txt %s' % joint_f_name cmd2='mv total_time.txt %s' % joint_f_name
os.popen(cmd2) os.popen(cmd2)

@ -21,7 +21,7 @@ echo $project_path
path=`pwd` path=`pwd`
#export SLEDGE_DISABLE_PREEMPTION=true #export SLEDGE_DISABLE_PREEMPTION=true
export SLEDGE_CPU_SPEED=2400 export SLEDGE_CPU_SPEED=2400
export SLEDGE_SCHEDULER=LLF export SLEDGE_SCHEDULER=EDF
export SLEDGE_SIGALRM_HANDLER=TRIAGED export SLEDGE_SIGALRM_HANDLER=TRIAGED
#export SLEDGE_SIGALRM_HANDLER=TRIAGED #export SLEDGE_SIGALRM_HANDLER=TRIAGED
#export SLEDGE_NWORKERS=1 #export SLEDGE_NWORKERS=1
@ -31,7 +31,8 @@ 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_multiple_image_processing_graph2.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

@ -5,26 +5,36 @@ function usage {
exit 1 exit 1
} }
chmod 400 ./id_rsa #chmod 400 ./id_rsa
path="/home/weihao/sledge/sledge_tree/runtime/tests" #path="/home/weihao/sledge/sledge_tree/runtime/tests"
path="/home/njl/sledge/runtime/tests"
#test single 5k c5 50% max RPS (500) #test single 5k c5 50% max RPS (480)
f1="5k_single_50.txt" f1="5k_single_50.txt"
server_log_file="execution_single_5k_50.log" server_log_file="execution_single_5k_50.log"
$path/start.sh $server_log_file >/dev/null 2>&1 & $path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running" echo "sledge is running"
./test_rps.sh $f1 120 50 5k.jpg 10000 2>&1 & ./test_rps.sh $f1 120 48 5k.jpg 10000 2>&1 &
pid1=$! pid1=$!
wait -f $pid1 wait $pid1
$path/kill_sledge.sh $path/kill_sledge.sh
#test single 5k c5 60% max RPS #test single 5k c5 70% max RPS
f1="5k_single_60.txt" f1="5k_single_70.txt"
server_log_file="execution_single_5k_60.log" server_log_file="execution_single_5k_70.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 68 5k.jpg 10000 2>&1 &
pid1=$!
wait $pid1
$path/kill_sledge.sh
#test single 5k c5 99% max RPS
f1="5k_single_99.txt"
server_log_file="execution_single_5k_99.log"
$path/start.sh $server_log_file >/dev/null 2>&1 & $path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running" echo "sledge is running"
./test_rps.sh $f1 120 60 5k.jpg 10000 2>&1 & ./test_rps.sh $f1 120 96 5k.jpg 10000 2>&1 &
pid1=$! pid1=$!
wait -f $pid1 wait $pid1
$path/kill_sledge.sh $path/kill_sledge.sh

@ -17,5 +17,5 @@ port=$5
#hey -disable-compression -disable-keepalive -disable-redirects -c 1 -q $rps -z $duration\s -cpus 1 -t 0 -m GET -D "$image" "http://10.10.1.1:$port" #hey -disable-compression -disable-keepalive -disable-redirects -c 1 -q $rps -z $duration\s -cpus 1 -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
#hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z 20s -t 0 -m GET -D "$image" "http://10.10.1.1:$port" #hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z 20s -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://10.10.1.1:$port" > $output hey -disable-compression -disable-keepalive -disable-redirects -c 5 -cpus 2 -q $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://10.10.1.1:$port" > $output

@ -0,0 +1,340 @@
{
"active": true,
"name": "resize1",
"path": "resize_wasm.so",
"port": 10000,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1", "lpd_wasm1"],
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp1",
"path": "C-Image-Manip_wasm.so",
"port": 10001,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_1"],
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "lpd_wasm1",
"path": "lpd_wasm.so",
"port": 10002,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "text/plain"
},
{
"active": true,
"name": "cifar10_1",
"path": "cifar10_wasm.so",
"port": 10003,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
},
{
"active": true,
"name": "work1",
"path": "work3_wasm.so",
"port": 10004,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 2,
"next_modules": [],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
},
{
"active": true,
"name": "resize1_2",
"path": "resize_wasm.so",
"port": 10005,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1_2", "lpd_wasm1_2"],
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp1_2",
"path": "C-Image-Manip_wasm.so",
"port": 10006,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_2"],
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "lpd_wasm1_2",
"path": "lpd_wasm.so",
"port": 10007,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1_2"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "cifar10_2",
"path": "cifar10_wasm.so",
"port": 10008,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1_2"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
},
{
"active": true,
"name": "work1_2",
"path": "work3_wasm.so",
"port": 10009,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 2,
"next_modules": [],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
},{
"active": true,
"name": "resize1_3",
"path": "resize_wasm.so",
"port": 10010,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1_3", "lpd_wasm1_3"],
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp1_3",
"path": "C-Image-Manip_wasm.so",
"port": 10011,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_3"],
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "lpd_wasm1_3",
"path": "lpd_wasm.so",
"port": 10012,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1_3"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "cifar10_3",
"path": "cifar10_wasm.so",
"port": 10013,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1_3"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "work1_3",
"path": "work3_wasm.so",
"port": 10014,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 2,
"next_modules": [],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "resize1_4",
"path": "resize_wasm.so",
"port": 10015,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1_4", "lpd_wasm1_4"],
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp1_4",
"path": "C-Image-Manip_wasm.so",
"port": 10016,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_4"],
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "lpd_wasm1_4",
"path": "lpd_wasm.so",
"port": 10017,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1_4"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "cifar10_4",
"path": "cifar10_wasm.so",
"port": 10018,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1_4"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "work1_4",
"path": "work3_wasm.so",
"port": 10019,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 2,
"next_modules": [],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
}

@ -0,0 +1,28 @@
Runtime Environment:
CPU Speed: 2400 MHz
Processor Speed: 2400 MHz
RLIMIT_DATA: Infinite
RLIMIT_NOFILE: 1048576
Core Count: 8
Listener core ID: 1
First Worker core ID: 2
Worker core count: 6
Scheduler Policy: MDL
Sigalrm Policy: BROADCAST
Preemption: Enabled
Quantum: 5000 us
Sandbox Performance Log: /home/hai/sledge/sledge/runtime/tests/runtime_sandbox_perf_log.log
Starting listener thread
Listener core thread: 7ffff7a006c0
Starting 6 worker thread(s)
C: 01, T: 0x7ffff7bfdd80, F: runtime_start_runtime_worker_threads>
Sandboxing environment ready!
C: 01, T: 0x7ffff7bfdd80, F: module_new>
Stack Size: 524288
C: 01, T: 0x7ffff7bfdd80, F: module_new>
Stack Size: 524288
C: 01, T: 0x7ffff7bfdd80, F: module_new>
Stack Size: 524288
C: 01, T: 0x7ffff7bfdd80, F: module_new>
Stack Size: 524288
Loading…
Cancel
Save