Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryang00 committed May 7, 2024
1 parent 6a9587b commit d905e8d
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 49 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ qemu_migrate
*_raw*
*funcs
*dmp
*bak
*bak
sb2
build_test
8 changes: 4 additions & 4 deletions artifact/common_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Binary file modified artifact/result/burst/burst.pdf
Binary file not shown.
53 changes: 26 additions & 27 deletions artifact/usecase_burst_computing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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"):
Expand All @@ -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)
Expand All @@ -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)")
Expand Down
3 changes: 3 additions & 0 deletions src/checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ std::ostringstream re{};
WriteStream *writer;
std::vector<std::unique_ptr<WAMRExecEnv>> 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();
Expand Down
3 changes: 3 additions & 0 deletions src/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ std::ostringstream re{};
FwriteStream *writer;
std::vector<std::unique_ptr<WAMRExecEnv>> as;
std::mutex as_mtx;
std::string offload_addr;
int offload_port;
std::string target;

std::vector<std::vector<std::pair<size_t, size_t>>> stack_record;
void unwind(WASMExecEnv *instance) {
Expand Down
19 changes: 7 additions & 12 deletions src/restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ ReadStream *reader;
WriteStream *writer;
WAMRInstance *wamr = nullptr;
std::vector<std::unique_ptr<WAMRExecEnv>> as;
std::string offload_addr;
int offload_port;
std::string target;

int main(int argc, char **argv) {
spdlog::cfg::load_env_levels();
Expand All @@ -49,11 +52,11 @@ int main(int argc, char **argv) {
std::cout << options.help() << std::endl;
exit(0);
}
auto target = result["target"].as<std::string>();
target = result["target"].as<std::string>();
auto source_addr = result["source_addr"].as<std::string>();
auto source_port = result["source_port"].as<int>();
auto offload_addr = result["offload_addr"].as<std::string>();
auto offload_port = result["offload_port"].as<int>();
offload_addr = result["offload_addr"].as<std::string>();
offload_port = result["offload_port"].as<int>();
auto count = result["count"].as<size_t>();
auto rdma = result["rdma"].as<bool>();

Expand All @@ -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<std::vector<std::unique_ptr<WAMRExecEnv>>>(*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
Expand Down
16 changes: 13 additions & 3 deletions src/wamr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ std::counting_semaphore<100> wakeup(0);
std::counting_semaphore<100> thread_init(0);
extern WriteStream *writer;
extern std::vector<std::unique_ptr<WAMRExecEnv>> 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('.');
Expand Down Expand Up @@ -509,8 +512,8 @@ void WAMRInstance::recover(std::vector<std::unique_ptr<WAMRExecEnv>> *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()) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/wamr_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/wamr_module_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d905e8d

Please sign in to comment.