Skip to content

Commit

Permalink
get optimistic computing monitoring done
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryang00 committed Mar 9, 2024
1 parent a9d88ae commit c77c600
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 97 deletions.
18 changes: 9 additions & 9 deletions artifact/bench_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
arg = [
[],
["stories110M.bin", "-z", "tokenizer.bin", "-t", "0.0"],
["./ORBvoc.txt,", "./TUM3.yaml", "./", "./associations/fr1_xyz.txt"],
["./ORBvoc.txt", "./TUM3.yaml", "./", "./associations/fr1_xyz.txt"],
[],
[],
[],
Expand All @@ -46,14 +46,14 @@
]
envs = [
"a=b",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=1",
"a=b",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=4",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"OMP_NUM_THREADS=1",
"a=b",
"a=b",
]
Expand Down Expand Up @@ -289,7 +289,7 @@ def plot(results):
.replace("-vn300", "")
.replace("maze-6404.txt", "")
.replace("stories110M.bin", "")
.replace("-z tokenizer.bin -t 0.0", "")
.replace("-z tokenizer.bin -t 0.0", "").replace("a=b", "")
.strip()
].append(( hcontainer_values, mvvm_values, qemu_x86_64_values,qemu_aarch64_values,native_values))

Expand Down
6 changes: 3 additions & 3 deletions artifact/bench_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def plot(results):
plt.savefig("performance_singlethread.pdf")

if __name__ == "__main__":
mvvm_results = run_mvvm()
write_to_csv("policy.csv")
# mvvm_results = run_mvvm()
# write_to_csv("policy.csv")
mvvm_results = read_from_csv("policy.csv")
plot(mvvm_results)
plot(mvvm_results)
24 changes: 14 additions & 10 deletions artifact/common_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time

pwd = "/mnt/MVVM"

slowtier = "epyc"

def get_func_index(func, file):
cmd = ["wasm2wat", "--enable-all", file]
Expand Down Expand Up @@ -280,7 +280,7 @@ def run_qemu_checkpoint(
return (exec, output)


def run(aot_file: str, arg: list[str], env: str, extra:str="") -> tuple[str, str]:
def run(aot_file: str, arg: list[str], env: str, extra: str = "") -> tuple[str, str]:
cmd = f"./MVVM_checkpoint -t ../build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra}"
print(cmd)
cmd = cmd.split()
Expand All @@ -294,25 +294,29 @@ def run(aot_file: str, arg: list[str], env: str, extra:str="") -> tuple[str, str
# print(output)
return (exec, output)


def run_checkpoint_restore_slowtier(
aot_file: str, folder, arg: list[str], env: str, extra:str=""
) -> tuple[str, str, str, str]:
aot_file: str, folder, arg: list[str], env: str, extra1: str = "", extra2 :str= ""
):
# Execute run_checkpoint and capture its result
res = []
for _ in range(trial):
checkpoint_result = run(aot_file, folder, arg, env,extra)
for i in range(trial):
os.system(f"./run_with_cpu_monitoring.sh ./MVVM_checkpoint -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra1} &")

# Execute run_restore with the same arguments (or modify as needed)
restore_result = run_criu_restore(aot_file, arg, env)
os.system(f"ssh {slowtier} ./run_with_cpu_monitoring.sh ./MVVM_restore -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra1} &")

# print(checkpoint_result, restore_result)
# Return a combined result or just the checkpoint result as needed

res.append(checkpoint_result[1] + restore_result[1])
res.append(f"./bench/{aot_file}{i}.log")
return (checkpoint_result[0], res)


def run_slowtier(aot_file: str, arg: list[str], env: str, extra:str="") -> tuple[str, str]:
cmd = f"ssh epyc {pwd}/MVVM_checkpoint -t {pwd}/build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra}"
def run_slowtier(
aot_file: str, arg: list[str], env: str, extra: str = ""
) -> tuple[str, str]:
cmd = f"ssh {slowtier} {pwd}/MVVM_checkpoint -t {pwd}/build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra}"
print(cmd)
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down
22 changes: 10 additions & 12 deletions artifact/result/comparison.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name,mvvm,hcontainer,qemu_x86_64,qemu_aach64,native
a=b linpack.aot,33.597456,21.068,36.012,0.051,24.056
OMP_NUM_THREADS=4 llama.aot stories110M.bin -z tokenizer.bin -t 0.0,10.116758,29.039,1187.058,0.051,7.054
"a=b rgbd_tum.aot ./ORBvoc.txt, ./TUM3.yaml ./ ./associations/fr1_xyz.txt",939.389244,0.001,0.045,0.051,0.006
OMP_NUM_THREADS=4 tc.aot,0.00049,0.012,0.029,0.048,0.003
OMP_NUM_THREADS=4 bt.aot,69.410827,131.075,1869.096,0.051,0.005
OMP_NUM_THREADS=4 cg.aot,29.317632,20.012,161.058,0.052,7.027
OMP_NUM_THREADS=4 ft.aot,15.010672,52.047,1550.071,0.051,0.005
OMP_NUM_THREADS=4 lu.aot,0.060571,0.047,1.067,0.051,0.006
OMP_NUM_THREADS=4 mg.aot,27.543796,13.053,764.02,0.051,0.005
OMP_NUM_THREADS=4 sp.aot,42.649225,1.08,55.073,0.05,2.062
a=b redis.aot,51.861305,124.087,368.022,0.055,0.004
a=b hdastar.aot maze-6404.txt 8,11.936914,0.012,11.067,0.049,0.002
a=b linpack.aot,24.743766,21.013,27.082,20.083,22.085
OMP_NUM_THREADS=1 llama.aot stories110M.bin -z tokenizer.bin -t 0.0,27.760763,24.099,27.082,146.043,29.091
OMP_NUM_THREADS=1 bt.aot,72.971184,133.0,0.005,1205.071,37.062
OMP_NUM_THREADS=1 cg.aot,27.552785,19.046,486.078,271.0,16.082
OMP_NUM_THREADS=1 ft.aot,32.585113,54.008,486.078,871.079,21.024
OMP_NUM_THREADS=1 lu.aot,0.056297,0.01,2.024,0.096,0.005
OMP_NUM_THREADS=1 mg.aot,26.387951,12.093,2464.017,279.036,9.065
OMP_NUM_THREADS=1 sp.aot,13.955374,1.056,116.063,16.001,1.043
a=b redis.aot,43.189769,127.083,328.08,428.015,18.09
a=b hdastar.aot maze-6404.txt 8,9.070406,0.0,11.03,0.004,4.082
27 changes: 27 additions & 0 deletions artifact/run_with_cpu_monitoring_mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
echo "$@"
"$@" &> $1.out &
pid1=$!
# echo $pid > /sys/fs/cgroup/memory/my_cgroup/cgroup.procs
# echo $(($first_arg * 1024 * 1024 * 1024)) > /sys/fs/cgroup/memory/my_cgroup/memory.limit_in_bytes
sudo asitop --show_cores &> $1.cpu.out &
pid2=$!
while true; do
line=$(ps auxh -q $pid1)
if [ "$line" == "" ]; then
break
fi
echo $line >>$1.ps.out
for child in $(pgrep -P $pid1); do
line=$(ps auxh -q $child)
if [ "$line" == "" ]; then
continue
fi
echo $line >>$1.ps.out
done
sleep 0.005
if ! ps -p $pid >/dev/null; then
sleep 0.5
sudo kill -9 $pid2
fi
done
24 changes: 24 additions & 0 deletions artifact/run_with_energy_monitoring.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
echo "$@"
"$@" &> $1.out &
pid1=$!
# echo $pid > /sys/fs/cgroup/memory/my_cgroup/cgroup.procs
# echo $(($first_arg * 1024 * 1024 * 1024)) > /sys/fs/cgroup/memory/my_cgroup/memory.limit_in_bytes
while true; do
line=$(ps auxh -q $pid1)
if [ "$line" == "" ]; then
break
fi
echo $line >>$1.energy.out
for child in $(pgrep -P $pid1); do
line=$(ps auxh -q $child)
if [ "$line" == "" ]; then
continue
fi
echo $line >>$1.energy.out
done
sleep 0.005
if ! ps -p $pid >/dev/null; then
sleep 0.5
fi
done
69 changes: 58 additions & 11 deletions artifact/usecase_burst_computing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import numpy as np
from collections import defaultdict


ip = ["128.114.53.32", "192.168.0.1"]
port = 1234
new_port = 1235
cmd = [
"redis", # low priority task
"rgbd_tum", # high priority task
"redis", # low priority task
"rgbd_tum", # high priority task
]
folder = [
"redis",
"ORB_SLAM2", # networkbound?
"ORB_SLAM2", # networkbound?
]
arg = [
[],
Expand All @@ -25,6 +27,7 @@

pool = Pool(processes=20)


def get_fasttier_result():
results = []
results1 = []
Expand All @@ -42,13 +45,25 @@ def get_fasttier_result():
print(exec, exec_time)
results.append((exec, exec_time)) # discover 4 aot_variant


def get_slowtier_result():
results = []
results1 = []
for _ in range(common_util.trial):
for i in range(len(cmd)):
aot = cmd[i] + ".aot"
results1.append(pool.apply_async(common_util.run_slowtier, (aot, arg[i], envs[i])))
results1.append(
pool.apply_async(
common_util.run_slowtier,
(
aot,
arg[i],
envs[i],
f"-i {ip[0]} -e {port}",
f"-o {ip[1]} -s {port}",
),
)
)
# print the results
results1 = [x.get() for x in results1]
for exec, output in results1:
Expand All @@ -59,14 +74,22 @@ def get_slowtier_result():
print(exec, exec_time)
results.append((exec, exec_time)) # discover 4 aot_variant


def get_snapshot_overhead():
results = []
results1 = []
for _ in range(common_util.trial):
for i in range(len(cmd)):
aot = cmd[i] + ".aot"
results1.append(pool.apply_async(common_util.run_checkpoint_restore_slowtier, (aot, arg[i], envs[i])))
# print the results
results1.append(
pool.apply_async(
common_util.run_checkpoint_restore_slowtier,
(aot, arg[i], envs[i]),
f"-o {ip[0]} -s {port}",
f"-i {ip[1]} -e {port} -o {ip[0]} -s {new_port}",
f"-i {ip[1]} -e {new_port}",
)
)
results1 = [x.get() for x in results1]
for exec, output in results1:
lines = output.split("\n")
Expand All @@ -76,13 +99,18 @@ def get_snapshot_overhead():
print(exec, exec_time)
results.append((exec, exec_time)) # discover 4 aot_variant


def get_burst_compute():
results = []
results1 = []
for _ in range(common_util.trial):
for i in range(len(cmd)):
aot = cmd[i] + ".aot"
results1.append(pool.apply_async(common_util.run_checkpoint_restore_slowtier, (aot, arg[i], envs[i])))
results1.append(
pool.apply_async(
common_util.run_checkpoint_restore_slowtier, (aot, arg[i], envs[i])
)
)
# print the results
results1 = [x.get() for x in results1]
for exec, output in results1:
Expand All @@ -94,13 +122,32 @@ def get_burst_compute():
results.append((exec, exec_time)) # discover 4 aot_variant


def write_to_csv(filename):
# 'data' is a list of tuples, e.g., [(checkpoint_result_0, checkpoint_result_1, restore_result_2), ...]
with open(filename, "a+", newline="") as csvfile:
writer = csv.writer(csvfile)
# Optionally write headers
writer.writerow(
[
"name",
"fasttier",
"slowtier",
"snapshot Time",
]
)

# Write the data
for idx, row in enumerate(fasttier):
writer.writerow([row[0], row[1], slowtier[1], snapshot[1]])


def plot():
fasttier = get_fasttier_result()
slowtier = get_slowtier_result()
snapshot = get_snapshot_overhead()
reu = get_burst_compute()
# plot skew
# plot skew
write_to_csv("burst_computing.csv")

results = read_from_csv("burst_computing.csv")
plot(results)
plot(results)
Loading

0 comments on commit c77c600

Please sign in to comment.