diff --git a/.env b/.env index bacb3d1..aa81b11 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -LD_LIBRARY_PATH=/home/weihao/sledge/sledge_tree/runtime/bin -SLEDGE_SCHEDULER=EDF -SLEDGE_SANDBOX_PERF_LOG=/home/weihao/sledge/sledge_tree/runtime_sandbox_perf_log.log +LD_LIBRARY_PATH=/home/hai/sledge/sledge/runtime/bin +SLEDGE_SCHEDULER=MDL +SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge/sledge/runtime/tests/runtime_sandbox_perf_log.log diff --git a/.gitignore b/.gitignore index 4fbb560..4f6067d 100644 --- a/.gitignore +++ b/.gitignore @@ -58,9 +58,9 @@ runtime/tests/**/*.txt runtime/tests/**/*.xlsx runtime/tests/test_data runtime/tests/*.log -data/*.txt -data/*.log -data/*.json +runtime/data/*.txt +runtime/data/*.log +runtime/data/*.json # Swap Files *.swp diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index de8156b..5f4dd1e 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -10,7 +10,8 @@ "USE_MEM_VM", "x86_64", "_GNU_SOURCE", - "LOG_TO_FILE" + "LOG_TO_FILE", + "DEEP_LEARN_SCHDUE" ], "cStandard": "${default}", "compilerPath": "/usr/bin/clang", diff --git a/.vscode/settings.json b/.vscode/settings.json index ab66fd5..0342667 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -113,7 +113,8 @@ "ostream": "c", "stop_token": "c", "dag_data_split.h": "c", - "scheduler.h": "c" + "scheduler.h": "c", + "priority_queue.h": "c" }, "files.exclude": { "**/.git": true, diff --git a/runtime/Makefile b/runtime/Makefile index 49f2b92..3374eca 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -41,6 +41,14 @@ BINARY_NAME=sledgert # Feature Toggles # 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 # Strips out calls to assert() and disables debuglog @@ -59,8 +67,11 @@ CFLAGS += -DLOG_TO_FILE # CFLAGS += -DLOG_PREEMPTION # CFLAGS += -DLOG_MODULE_LOADING # CFLAGS += -DOPT_AVOID_GLOBAL_QUEUE -CFLAGS += -DLOG_RUNTIME_FILE_LOG -#CFLAGS += -DLOG_RUNTIME_MEM_LOG +# CFLAGS += -DLOG_RUNTIME_FILE_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 # page is allocated. This helps understand the relationship to memory allocation and execution time. diff --git a/data/get_average.py b/runtime/data/get_average.py similarity index 100% rename from data/get_average.py rename to runtime/data/get_average.py diff --git a/runtime/data/polt.py b/runtime/data/polt.py new file mode 100644 index 0000000..f98c570 --- /dev/null +++ b/runtime/data/polt.py @@ -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() diff --git a/data/split_logs.py b/runtime/data/split_logs.py similarity index 100% rename from data/split_logs.py rename to runtime/data/split_logs.py diff --git a/data/txt_split.py b/runtime/data/txt_split.py similarity index 100% rename from data/txt_split.py rename to runtime/data/txt_split.py diff --git a/runtime/include/global_request_scheduler.h b/runtime/include/global_request_scheduler.h index 5ec14d8..1b13870 100644 --- a/runtime/include/global_request_scheduler.h +++ b/runtime/include/global_request_scheduler.h @@ -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_if_earlier_fn_t)(struct sandbox_request **, uint64_t); typedef uint64_t (*global_request_scheduler_peek_fn_t)(void); +typedef int (*global_request_scheduler_size_fn_t)(void); struct global_request_scheduler_config { global_request_scheduler_add_fn_t add_fn; global_request_scheduler_remove_fn_t remove_fn; global_request_scheduler_remove_if_earlier_fn_t remove_if_earlier_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_if_earlier(struct sandbox_request **, uint64_t targed_deadline); uint64_t global_request_scheduler_peek(void); +int global_request_scheduler_size(void); \ No newline at end of file diff --git a/runtime/include/module.h b/runtime/include/module.h index f4c3d6c..358b623 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -39,7 +39,14 @@ #warning \ "MODULE_MAX_PENDING_CLIENT_REQUESTS likely exceeds the value in /proc/sys/net/core/somaxconn and thus may be silently truncated"; #endif - +#ifdef DEEP_LEARN_SCHDUE +struct MDL +{ + int hash_node; + int global_queue_node; + int http_data_size; +}; +#endif struct module { char name[MODULE_MAX_NAME_LENGTH]; char path[MODULE_MAX_PATH_LENGTH]; @@ -85,6 +92,9 @@ struct module { uint32_t pre_module_count; bool runtime_visited; /* used for calculating the estimated time */ 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 }; /************************* diff --git a/runtime/include/perf_window.h b/runtime/include/perf_window.h index 74f185e..008a839 100644 --- a/runtime/include/perf_window.h +++ b/runtime/include/perf_window.h @@ -24,7 +24,9 @@ perf_window_initialize(struct perf_window *self, char* module_name) self->count = 0; 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); +#ifdef GET_AVER_TIME 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_duration[i] = (struct execution_node){ .execution_time = value, .by_termination_idx = i }; +#ifdef GET_AVER_TIME self->by_duration_for_mdl[i] = value; +#endif } self->count = PERF_WINDOW_BUFFER_SIZE; goto done; } /* Otherwise, replace the oldest value, and then sort */ +#ifdef GET_AVER_TIME 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]; 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; } +#ifdef GET_AVER_TIME static inline uint64_t perf_window_get_average(struct perf_window *self) { @@ -181,6 +188,7 @@ perf_window_get_average(struct perf_window *self) return average; } } +#endif /** * Returns the total count of executions diff --git a/runtime/include/perf_window_t.h b/runtime/include/perf_window_t.h index 699be35..22381b2 100644 --- a/runtime/include/perf_window_t.h +++ b/runtime/include/perf_window_t.h @@ -26,7 +26,9 @@ struct execution_node { struct perf_window { char name[32]; struct execution_node by_duration[PERF_WINDOW_BUFFER_SIZE]; +#ifdef GET_AVER_TIME uint64_t by_duration_for_mdl[PERF_WINDOW_BUFFER_SIZE]; +#endif uint16_t by_termination[PERF_WINDOW_BUFFER_SIZE]; uint64_t count; lock_t lock; diff --git a/runtime/include/priority_queue.h b/runtime/include/priority_queue.h index 0cc2c5e..0e6c71b 100644 --- a/runtime/include/priority_queue.h +++ b/runtime/include/priority_queue.h @@ -298,7 +298,9 @@ static inline int priority_queue_length_nolock(struct priority_queue *self) { assert(self != NULL); +#ifndef DEEP_LEARN_SCHDUE assert(!listener_thread_is_running()); +#endif assert(!self->use_lock || LOCK_IS_LOCKED(&self->lock)); return self->size; diff --git a/runtime/include/sandbox_functions.h b/runtime/include/sandbox_functions.h index 4f05d21..119f506 100644 --- a/runtime/include/sandbox_functions.h +++ b/runtime/include/sandbox_functions.h @@ -266,3 +266,20 @@ sandbox_mem_print_perf(struct sandbox *sandbox) 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 +} diff --git a/runtime/include/sandbox_set_as_complete.h b/runtime/include/sandbox_set_as_complete.h index b86e959..559a602 100644 --- a/runtime/include/sandbox_set_as_complete.h +++ b/runtime/include/sandbox_set_as_complete.h @@ -59,6 +59,9 @@ sandbox_set_as_complete(struct sandbox *sandbox, sandbox_state_t last_state) /* Terminal State Logging */ sandbox_print_perf(sandbox); sandbox_mem_print_perf(sandbox); + #ifdef DEEP_LEARN_SCHDUE + sandbox_MDL_print_perf(sandbox); + #endif sandbox_summarize_page_allocations(sandbox); /* Do not touch sandbox state after adding to completion queue to avoid use-after-free bugs */ diff --git a/runtime/include/sandbox_set_as_error.h b/runtime/include/sandbox_set_as_error.h index cf34523..c56cedb 100644 --- a/runtime/include/sandbox_set_as_error.h +++ b/runtime/include/sandbox_set_as_error.h @@ -54,6 +54,9 @@ sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state) sandbox->state = SANDBOX_ERROR; sandbox_print_perf(sandbox); sandbox_mem_print_perf(sandbox); + #ifdef DEEP_LEARN_SCHDUE + sandbox_MDL_print_perf(sandbox); + #endif sandbox_summarize_page_allocations(sandbox); sandbox_free_linear_memory(sandbox); admissions_control_subtract(sandbox->admissions_estimate); diff --git a/runtime/src/admissions_info.c b/runtime/src/admissions_info.c index 5bc4b6e..91e9def 100644 --- a/runtime/src/admissions_info.c +++ b/runtime/src/admissions_info.c @@ -43,6 +43,7 @@ admission_info_get_percentile(struct admissions_info *self) return estimated_execution; } +#ifdef GET_AVER_TIME /* * Get the average execution time of this module, no lock for accessing the queue * @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); return estimated_execution; } +#endif /* * Adds an execution value to the perf window and calculates and caches and updated estimate diff --git a/runtime/src/current_sandbox.c b/runtime/src/current_sandbox.c index d9d431d..a1aa918 100644 --- a/runtime/src/current_sandbox.c +++ b/runtime/src/current_sandbox.c @@ -13,6 +13,13 @@ extern uint64_t system_start_timestamp; lock_t lock; +#ifdef DEEP_LEARN_SCHDUE + +_Atomic uint32_t hash_count = 0; + +#endif + + #define OUTPUT_BUFER_SIZE 1024*5 __thread struct sandbox *worker_thread_current_sandbox = NULL; @@ -87,6 +94,9 @@ current_sandbox_start(void) if(sandbox_req_map == NULL) { sandbox_req_map = malloc(sizeof(struct hashmap)); +#ifdef DEEP_LEARN_SCHDUE + atomic_init(&hash_count, 0); +#endif map_init(sandbox_req_map); } if(sandbox_request_id == NULL) @@ -178,7 +188,18 @@ current_sandbox_start(void) } memcpy(individual_pre_func_output, pre_func_output, output_length); 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 = sandbox_request_allocate(next_module_node, false, sandbox->request_length, next_module_node->name, sandbox->client_socket_descriptor, @@ -253,7 +274,18 @@ current_sandbox_start(void) uint64_t now = __getcycles(); current_sandbox_get_newlaxity(sandbox, now); //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 = sandbox_request_allocate(next_module_node, false, sandbox->request_length, 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_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; +#ifdef DEEP_LEARN_SCHDUE + atomic_fetch_add(&hash_count, 1); +#endif } LOCK_UNLOCK(&lock); 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); map_delete(sandbox_req_map, 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); } diff --git a/runtime/src/global_request_scheduler.c b/runtime/src/global_request_scheduler.c index 85611f5..cfc3c46 100644 --- a/runtime/src/global_request_scheduler.c +++ b/runtime/src/global_request_scheduler.c @@ -91,3 +91,8 @@ global_request_scheduler_peek() { return global_request_scheduler.peek_fn(); } + +int +global_request_scheduler_size(){ + return global_request_scheduler.size_fn(); +} \ No newline at end of file diff --git a/runtime/src/global_request_scheduler_minheap.c b/runtime/src/global_request_scheduler_minheap.c index fb60446..86a896d 100644 --- a/runtime/src/global_request_scheduler_minheap.c +++ b/runtime/src/global_request_scheduler_minheap.c @@ -64,6 +64,12 @@ global_request_scheduler_minheap_peek(void) 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 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, .remove_fn = global_request_scheduler_minheap_remove, .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); diff --git a/runtime/src/listener_thread.c b/runtime/src/listener_thread.c index c0b3042..6a3c92c 100644 --- a/runtime/src/listener_thread.c +++ b/runtime/src/listener_thread.c @@ -9,10 +9,13 @@ #include "runtime.h" #include "scheduler.h" +#ifdef DEEP_LEARN_SCHDUE +extern _Atomic uint32_t hash_count; +#endif 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*/ -const int QUEUE_SIZE = 16; +const int QUEUE_SIZE = 36; /* * 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. @@ -178,6 +181,30 @@ listener_thread_main(void *dummy) 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 */ uint64_t estimated_execution_time = 0; int front = 0, rear = 0; @@ -190,15 +217,11 @@ listener_thread_main(void *dummy) { estimated_execution_time += admission_info_get_percentile(¤t_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(¤t_module->admissions_info); - estimated_execution_model = admission_info_get_average(¤t_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; +#ifdef GET_AVER_TIME + estimated_execution_time += admission_info_get_average(¤t_module->admissions_info); +#else + estimated_execution_time += admission_info_get_percentile(¤t_module->admissions_info); +#endif } 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) diff --git a/runtime/src/main.c b/runtime/src/main.c index 415be7c..06b9cb3 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -231,9 +231,13 @@ runtime_configure() printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path); runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w"); if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); } - fprintf(runtime_sandbox_perf_log, "threadid,id,function,state,deadline,actual,queued,initializing,runnable," + +#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," "running,blocked,returned,memory\n"); - //fflush(runtime_sandbox_perf_log); +#endif } else { printf("\tSandbox Performance Log: Disabled\n"); } diff --git a/runtime/src/module.c b/runtime/src/module.c index 61e483d..4e6f2ff 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -19,7 +19,7 @@ const int JSON_MAX_ELEMENT_COUNT = 16; const int JSON_MAX_ELEMENT_SIZE = 1024; -const int PRE_MODULE_COUNT = 4; +const int MODULE_MAX_COUNT = 36; /************************* * Private Static Inline * @@ -375,7 +375,7 @@ module_new_from_json(char *file_name) int module_count = 0; char *request_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) { panic("Memory allocation failed for nodes array\n"); } @@ -616,12 +616,17 @@ module_new_from_json(char *file_name) } } - module->next_module_count = next_module_count; - module->pre_module_count = pre_module_count; - module->next_module = NULL; - module->pre_module = NULL; - module->runtime_visited = false; - module->run_priority = priority; + module->next_module_count = next_module_count; + module->pre_module_count = pre_module_count; + module->next_module = NULL; + module->pre_module = NULL; + module->runtime_visited = false; + 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); module_set_http_info(module, request_count, request_headers, request_content_type, diff --git a/runtime/tests/hey_test_8c.sh b/runtime/tests/hey_test_8c.sh index 8cfb6e8..f8b753d 100755 --- a/runtime/tests/hey_test_8c.sh +++ b/runtime/tests/hey_test_8c.sh @@ -25,9 +25,9 @@ pid2=$! pid3=$! ./test_8c.sh $f4 $duration $concurrency 40k.jpg 10009 2>&1 & pid4=$! -wait -f $pid1 -wait -f $pid2 -wait -f $pid3 -wait -f $pid4 +wait $pid1 +wait $pid2 +wait $pid3 +wait $pid4 printf "[OK]\n" diff --git a/runtime/tests/parse_parse_python.py b/runtime/tests/parse_parse_python.py index 7f7613e..33cbff5 100644 --- a/runtime/tests/parse_parse_python.py +++ b/runtime/tests/parse_parse_python.py @@ -36,7 +36,7 @@ def get_values(key, value, miss_deadline_rate, total_latency, running_times, pre before_dot = file_name.split(".")[0] 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() cmd2='mv total_time.txt %s' % joint_f_name os.popen(cmd2) diff --git a/runtime/tests/start.sh b/runtime/tests/start.sh index e67585f..28d9c8a 100755 --- a/runtime/tests/start.sh +++ b/runtime/tests/start.sh @@ -21,7 +21,7 @@ echo $project_path path=`pwd` #export SLEDGE_DISABLE_PREEMPTION=true 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_NWORKERS=1 @@ -31,7 +31,8 @@ echo $SLEDGE_SANDBOX_PERF_LOG 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/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 diff --git a/runtime/tests/start_test_gragh_single.sh b/runtime/tests/start_test_gragh_single.sh index daa2b7c..4b6c1e7 100755 --- a/runtime/tests/start_test_gragh_single.sh +++ b/runtime/tests/start_test_gragh_single.sh @@ -5,26 +5,36 @@ function usage { exit 1 } -chmod 400 ./id_rsa -path="/home/weihao/sledge/sledge_tree/runtime/tests" - -#test single 5k c5 50% max RPS (500) +#chmod 400 ./id_rsa +#path="/home/weihao/sledge/sledge_tree/runtime/tests" +path="/home/njl/sledge/runtime/tests" +#test single 5k c5 50% max RPS (480) f1="5k_single_50.txt" server_log_file="execution_single_5k_50.log" $path/start.sh $server_log_file >/dev/null 2>&1 & 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=$! -wait -f $pid1 +wait $pid1 $path/kill_sledge.sh -#test single 5k c5 60% max RPS -f1="5k_single_60.txt" -server_log_file="execution_single_5k_60.log" +#test single 5k c5 70% max RPS +f1="5k_single_70.txt" +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 & 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=$! -wait -f $pid1 +wait $pid1 $path/kill_sledge.sh \ No newline at end of file diff --git a/runtime/tests/test_8c.sh b/runtime/tests/test_8c.sh index 4cacffb..b60abeb 100755 --- a/runtime/tests/test_8c.sh +++ b/runtime/tests/test_8c.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 $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 diff --git a/runtime/tests/test_multiple_image_processing_graph2.json b/runtime/tests/test_multiple_image_processing_graph2.json new file mode 100644 index 0000000..9076480 --- /dev/null +++ b/runtime/tests/test_multiple_image_processing_graph2.json @@ -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", + } \ No newline at end of file diff --git a/sledge.log b/sledge.log new file mode 100755 index 0000000..2ea78f9 --- /dev/null +++ b/sledge.log @@ -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