diff --git a/.gitignore b/.gitignore index 4bde902..51f119f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ qemu_migrate *_raw* *funcs *dmp -*bak \ No newline at end of file +*bak +sb2 +build_test \ No newline at end of file diff --git a/artifact/common_util.py b/artifact/common_util.py index e6172be..273b600 100644 --- a/artifact/common_util.py +++ b/artifact/common_util.py @@ -1230,10 +1230,10 @@ def run_qemu_aarch64( if __name__ == "__main__": - print(get_func_index("$recv ", "./test/tcp_client.wasm")) - print(get_func_index("printf", "./test/read-file.wasm")) - print(get_func_index("sendto", "./test/client.wasm")) - print(get_func_index("atomic_wait", "./bench/hdastar.wasm")) + print(get_func_index("__wasilibc_nocwd_openat_nomode", "./bench/rgbd_tum.wasm")) + # print(get_func_index("printf", "./test/read-file.wasm")) + # print(get_func_index("sendto", "./test/client.wasm")) + # print(get_func_index("atomic_wait", "./bench/hdastar.wasm")) plot_whole(["policy.csv", "policy_multithread.csv", "policy_mac.csv"], "policy.pdf") # read_csv_from_file("policy.csv") diff --git a/artifact/result/burst/burst.pdf b/artifact/result/burst/burst.pdf index a9d5575..28ca074 100644 Binary files a/artifact/result/burst/burst.pdf and b/artifact/result/burst/burst.pdf differ diff --git a/artifact/usecase_burst_computing.py b/artifact/usecase_burst_computing.py index c6b3bdb..2fce0c4 100644 --- a/artifact/usecase_burst_computing.py +++ b/artifact/usecase_burst_computing.py @@ -160,6 +160,10 @@ def read_from_csv(filename): def plot_time(reu, aot_energy, aot_ps, aot1_energy, aot1_ps): # get from reu # start time -> end time -> start time + font = {"size": 18} + + plt.rc("font", **font) + reu = reu.replace("\\n", "\n").replace("\\r", "\n").split("\n") state = 0 time = [] @@ -170,13 +174,13 @@ def plot_time(reu, aot_energy, aot_ps, aot1_energy, aot1_ps): if line.__contains__("ttrack"): to_append = float(line.split(" ")[-1]) # print("exec_time ",exec_time[-1]) - if to_append >= 0: - exec_time[state].append( to_append + 0.2) + if to_append >= 0 and to_append < 1: + exec_time[state].append(to_append) if line.__contains__("Iteration"): to_append = float(line.split(" ")[-2].replace("\\r", "")) - if to_append > 0: + if to_append > 0 and to_append < 1: # print(state) - exec_time1[state-5].append(to_append) + exec_time1[state - 5].append(to_append) # print(exec_time) # print("exec_time ",exec_time[-1]) if line.__contains__("Snapshot"): @@ -195,29 +199,21 @@ def plot_time(reu, aot_energy, aot_ps, aot1_energy, aot1_ps): print(line) # pass print(e) - print(exec_time) - # print(exec_time1) + # print(exec_time) + # print(exec_time1[0]) # print(time) # record time - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=(20, 10)) base = time[0] - sum(exec_time[0]) - sum_aot = ( - exec_time[0] - + exec_time[1] - + exec_time[2] - + exec_time[3] - + exec_time[4] - ) - sum_aot1 = ( - exec_time1[0] + exec_time1[1] + exec_time1[2] + exec_time1[3] - ) + sum_aot = exec_time[0] + exec_time[1] + exec_time[2] + exec_time[3] + exec_time[4] + sum_aot1 = exec_time1[0] + exec_time1[1] + exec_time1[2] + exec_time1[3] time_spots = [time[0] - sum(exec_time[0]) - base] for idx, i in enumerate(exec_time): to_pop = len(i) - 1 for x in i: # Add the current increment to the last time spot - new_time_spot = time_spots[-1] + x + new_time_spot = time_spots[-1] + x * 500 # Append the new time spot to the sequence time_spots.append(new_time_spot) time_spots.pop(to_pop) @@ -236,15 +232,18 @@ def plot_time(reu, aot_energy, aot_ps, aot1_energy, aot1_ps): # Append the new time spot to the sequence time_spots1.append(new_time_spot) time_spots1.pop(to_pop) - if idx != len(exec_time1) -1: - time_spots1.append(time[idx + 6] - sum(exec_time1[idx+1]) - base) - avg_extended, percentile99_extended = get_avg_99percent(sum_aot,1) - sum_aot1 = [x*30000 for x in sum_aot1 ] - avg_exec_time1, percentile_99_exec_time1 = get_avg_99percent(sum_aot1,10000) - ax.plot(time_spots, avg_extended, "blue") - ax.plot(time_spots, percentile99_extended, color="purple", linestyle="-") - ax.plot(time_spots1, avg_exec_time1, "r") - ax.plot(time_spots1, percentile_99_exec_time1, color="pink", linestyle="-") + if idx != len(exec_time1) - 1: + time_spots1.append(time[idx + 6] - sum(exec_time1[idx + 1]) - base) + # sum_aot = [x * 50000 for x in sum_aot] + avg_extended, percentile99_extended = get_avg_99percent(sum_aot, 1) + sum_aot1 = [x * 10 for x in sum_aot1] + avg_exec_time1, percentile_99_exec_time1 = get_avg_99percent(sum_aot1, 10000) + ax.plot(time_spots, avg_extended, "blue",label="OrbSlam2") + # ax.plot(time_spots, percentile99_extended, color="purple", linestyle="-") + ax.plot(time_spots1, avg_exec_time1, "r",label="Redis") + # ax.plot(time_spots1, percentile_99_exec_time1, color="pink", linestyle="-") + # Add a legend to the plot + ax.legend() # ax.plot(time_spots,sum_aot, "blue") # ax.plot(time_spots1,sum_aot1, "r") ax.set_xlabel("Time (s)") diff --git a/src/checkpoint.cpp b/src/checkpoint.cpp index df508f7..7a63fcd 100644 --- a/src/checkpoint.cpp +++ b/src/checkpoint.cpp @@ -29,6 +29,9 @@ std::ostringstream re{}; WriteStream *writer; std::vector> as; std::mutex as_mtx; +std::string offload_addr; +int offload_port; +std::string target; int main(int argc, char *argv[]) { spdlog::cfg::load_env_levels(); diff --git a/src/profile.cpp b/src/profile.cpp index 7be0757..278c913 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -30,6 +30,9 @@ std::ostringstream re{}; FwriteStream *writer; std::vector> as; std::mutex as_mtx; +std::string offload_addr; +int offload_port; +std::string target; std::vector>> stack_record; void unwind(WASMExecEnv *instance) { diff --git a/src/restore.cpp b/src/restore.cpp index 6ea084f..fc2b6fd 100644 --- a/src/restore.cpp +++ b/src/restore.cpp @@ -28,6 +28,9 @@ ReadStream *reader; WriteStream *writer; WAMRInstance *wamr = nullptr; std::vector> as; +std::string offload_addr; +int offload_port; +std::string target; int main(int argc, char **argv) { spdlog::cfg::load_env_levels(); @@ -49,11 +52,11 @@ int main(int argc, char **argv) { std::cout << options.help() << std::endl; exit(0); } - auto target = result["target"].as(); + target = result["target"].as(); auto source_addr = result["source_addr"].as(); auto source_port = result["source_port"].as(); - auto offload_addr = result["offload_addr"].as(); - auto offload_port = result["offload_port"].as(); + offload_addr = result["offload_addr"].as(); + offload_port = result["offload_port"].as(); auto count = result["count"].as(); auto rdma = result["rdma"].as(); @@ -76,16 +79,8 @@ int main(int argc, char **argv) { reader = new SocketReadStream(source_addr.c_str(), source_port); #endif auto a = struct_pack::deserialize>>(*reader).value(); - // sleep(10); - if (offload_addr.empty()) - writer = new FwriteStream((removeExtension(target) + ".bin").c_str()); + #if !defined(_WIN32) -#if __linux__ - else if(rdma) - writer = new RDMAWriteStream(offload_addr.c_str(), offload_port); -#endif - else - writer = new SocketWriteStream(offload_addr.c_str(), offload_port); // is server for all and the is server? if (!a[a.size() - 1] ->module_inst.wasi_ctx.socket_fd_map.empty()) { // new ip, old ip // only if tcp requires keepalive diff --git a/src/wamr.cpp b/src/wamr.cpp index cb25c2c..7c7861b 100644 --- a/src/wamr.cpp +++ b/src/wamr.cpp @@ -43,6 +43,9 @@ std::counting_semaphore<100> wakeup(0); std::counting_semaphore<100> thread_init(0); extern WriteStream *writer; extern std::vector> as; +extern std::string offload_addr; +extern int offload_port; +extern std::string target; std::string removeExtension(std::string &filename) { size_t dotPos = filename.find_last_of('.'); @@ -509,8 +512,8 @@ void WAMRInstance::recover(std::vector> *e_) { instantiate(); this->time = std::chrono::high_resolution_clock::now(); invoke_init_c(); - // std::string stdout = "/dev/stdout"; - // invoke_fopen(stdout, 2); + std::string stdout = "/dev/stdout"; + invoke_preopen(1, stdout); restore(execEnv.front(), cur_env); if (tid_start_arg_map.find(execEnv.back()->cur_count) != tid_start_arg_map.end()) { @@ -816,7 +819,14 @@ long get_rss() { void serialize_to_file(WASMExecEnv *instance) { // gateway auto start = std::chrono::high_resolution_clock::now(); - + if (writer == nullptr) { + if (offload_addr.empty()) + writer = new FwriteStream((removeExtension(target) + ".bin").c_str()); +#if __linux__ + else + writer = new SocketWriteStream(offload_addr.c_str(), offload_port); +#endif + } #if WASM_ENABLE_LIB_PTHREAD != 0 auto cluster = wasm_exec_env_get_cluster(instance); auto all_count = bh_list_length(&cluster->exec_env_list); diff --git a/src/wamr_export.cpp b/src/wamr_export.cpp index ad7ca9a..006e16e 100644 --- a/src/wamr_export.cpp +++ b/src/wamr_export.cpp @@ -499,7 +499,7 @@ void segfault_handler(int sig) { void sigtrap_handler(int sig) { // fprintf(stderr, "Caught signal %d, performing custom logic...\n", sig); auto exec_env = wamr->get_exec_env(); - wamr->get_inst_diff(); + // wamr->get_inst_diff(); if (sig == SIGSEGV) { serialize_to_file(exec_env); } diff --git a/src/wamr_module_instance.cpp b/src/wamr_module_instance.cpp index 01fb5b1..ebbc3c8 100644 --- a/src/wamr_module_instance.cpp +++ b/src/wamr_module_instance.cpp @@ -79,7 +79,7 @@ void WAMRModuleInstance::restore_impl(WASMModuleInstance *env) { } env->table_count = tables.size(); } - env->global_table_data.memory_instances[0] = **env->memories; + //env->global_table_data.memory_instances[0] = **env->memories; if (wamr->is_aot) { auto module = (AOTModule *)env->module; module->aux_data_end_global_index = aux_data_end_global_index;