Skip to content

Commit

Permalink
get optimistic result
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryang00 committed Mar 13, 2024
1 parent 10eebf6 commit 1c49a37
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 138 deletions.
154 changes: 124 additions & 30 deletions artifact/common_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import asyncio
import time

pwd = "/home/victoryang00/MVVM"
slowtier = "dennard.soe.ucsc.edu"
# pwd = "/Users/victoryang00/Documents/project/MVVM-bench/"
pwd = "/mnt/MVVM"
slowtier = "epyc"
burst = "mac"


Expand Down Expand Up @@ -46,7 +47,7 @@ def get_func_index(func, file):
"-ckpt-loop.aot",
"-ckpt-loop-dirty.aot",
]
trial = 10
trial = 2


def contains_result(output: str, result: str) -> bool:
Expand Down Expand Up @@ -297,68 +298,161 @@ def run(aot_file: str, arg: list[str], env: str, extra: str = "") -> tuple[str,
return (exec, output)


def run_checkpoint_restore_slowtier(
def run_checkpoint_restore_slowtier_overhead(
aot_file: str,
folder,
arg: list[str],
env: str,
extra1: str = "",
extra2: str = "",
extra3: str = "",
):
# Execute run_checkpoint and capture its result
res = []
for i in range(trial):
os.system(
f"../artifact/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)
os.system(
f"ssh {slowtier} {pwd}/artifact/run_with_cpu_monitoring.sh {pwd}/build/MVVM_restore -t {pwd}/build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra2} &"
f"ssh -t {slowtier} {pwd}/build/MVVM_restore -t {pwd}/build/bench/{aot_file} {extra2} &"
)
print(
f"ssh -t {slowtier} {pwd}/build/MVVM_restore -t {pwd}/build/bench/{aot_file} {extra2} &"
)
os.system("sleep 15")

os.system(
f"../artifact/run_with_cpu_monitoring.sh ./MVVM_restore -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra3} &"
f"./MVVM_checkpoint -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra1} >> ./bench/{aot_file}{i}.log &"
)
print(
f"./MVVM_checkpoint -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra1} > ./bench/{aot_file}{i}.log &"
)
os.system("sleep 10")
os.system("pkill -SIGINT -f MVVM_checkpoint")
os.system("pkill -SIGINT -f MVVM_checkpoint")
os.system(f"ssh {slowtier} pkill -f MVVM_restore")
# os.system(f"ssh {slowtier} tcpkill -i eno2 port 12346")
# print(checkpoint_result, restore_result)
# Return a combined result or just the checkpoint result as needed

res.append(f"./bench/{aot_file}{i}.log")
os.system("sleep 5")
cmd = f"cat ./bench/{aot_file}{i}.log"
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output = result.stdout.decode("utf-8")
except:
output = result.stdout
# print(output)
exec = " ".join([env] + [aot_file] + arg)
res.append((exec, output))
return res


def run_checkpoint_restore_burst(
def run_checkpoint_restore_slowtier(
aot_file: str,
folder,
arg: list[str],
aot_file1: str,
arg1: list[str],
env: str,
extra1: str = "",
extra2: str = "",
extra3: str = "",
):
# Execute run_checkpoint and capture its result
res = []
for i in range(trial):
os.system(
f"../artifact/run_with_energy_monitoring.sh ./MVVM_checkpoint -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra1} &"
)
os.system("rm ./*.out")
os.system(f"ssh -t {slowtier} rm {pwd}/build/*.out")
# Execute run_restore with the same arguments (or modify as needed)
os.system(
f"script -q /dev/null -c 'ssh -t {slowtier} {pwd}/build/MVVM_restore -t {pwd}/build/bench/{aot_file1} {extra2}' >> MVVM_restore.1.out &"
)
os.system(f"ssh -t {slowtier} {pwd}/artifact/run_with_cpu_monitoring_nocommand.sh MVVM_restore &")
os.system(
f"script -q /dev/null -c './MVVM_restore -t ./bench/{aot_file1} {extra3}' >> MVVM_restore.out &"
)
os.system(f"../artifact/run_with_cpu_monitoring_nocommand.sh MVVM_restore &")

os.system("sleep 15")
os.system(
f"../artifact/run_with_cpu_monitoring.sh ./MVVM_checkpoint -t ./bench/{aot_file1} {' '.join(['-a ' + str(x) for x in arg1])} -e {env} {extra1} &"
)
os.system("mv MVVM_checkpoint.out MVVM_checkpoint.1.out")
os.system("mv MVVM_checkpoint.ps.out MVVM_checkpoint.ps.1.out")
os.system("sleep 10")
os.system(f"pkill -SIGINT -f MVVM_checkpoint")
os.system(
f"../artifact/run_with_cpu_monitoring.sh ./MVVM_checkpoint -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env}"
)
os.system(f"ssh -t {slowtier} pkill -SIGINT -f MVVM_restore")

# print(checkpoint_result, restore_result)
# Return a combined result or just the checkpoint result as needed
os.system("sleep 100")

cmd = f"cat ./MVVM_checkpoint.out ./MVVM_checkpoint.1.out ./MVVM_restore.1.out ./MVVM_restore.out"
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output = result.stdout.decode("utf-8")
except:
output = result.stdout

exec = " ".join([env] + [aot_file] + arg)
res.append((exec, output))
return res

# Execute run_restore with the same arguments (or modify as needed)
os.system(
f"ssh {burst} {pwd}/artifact/run_with_energy_monitoring_mac.sh {pwd}/build/MVVM_restore -t {pwd}/build/bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra2} &"
)

os.system(
f"../artifact/run_with_energy_monitoring.sh ./MVVM_restore -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env} {extra3} &"
)
# print(checkpoint_result, restore_result)
# Return a combined result or just the checkpoint result as needed
def run_checkpoint_restore_burst(
aot_file: str,
arg: list[str],
aot_file1: str,
arg1: list[str],
env: str,
extra1: str = "",
extra2: str = "",
extra3: str = "",
):
# Execute run_checkpoint and capture its result
res = []
os.system("rm ./*.out")
os.system(f"ssh -t {burst} rm {pwd}/build/*.out")
# Execute run_restore with the same arguments (or modify as needed)
os.system(
f"script -q /dev/null -c 'ssh -t {burst} {pwd}/build/MVVM_restore -t {pwd}/build/bench/{aot_file1} {extra2}' >> MVVM_restore.1.out &"
)
os.system(f"ssh -t {burst} ../artifact/run_with_energy_monitoring.sh MVVM_restore 1 &")
os.system(
f"script -q /dev/null -c './MVVM_restore -t ./bench/{aot_file1} {extra3}' >> MVVM_restore.out &"
)
os.system(f"../artifact/run_with_energy_monitoring.sh MVVM_restore 2 &")

os.system("sleep 15")
os.system(
f"./MVVM_checkpoint -t ./bench/{aot_file1} {' '.join(['-a ' + str(x) for x in arg1])} -e {env} {extra1} &"
)
os.system("../artifact/run_with_energy_monitoring.sh MVVM_checkpoint 1 &")

res.append(f"./bench/{aot_file}{i}.log")
os.system("sleep 10")
os.system(f"pkill -SIGINT -f MVVM_checkpoint")
os.system(
f"../artifact/run_with_energy_monitoring_mac.sh ./MVVM_checkpoint -t ./bench/{aot_file} {' '.join(['-a ' + str(x) for x in arg])} -e {env}"
)
os.system(f"ssh -t {burst} pkill -SIGINT -f MVVM_restore")

# print(checkpoint_result, restore_result)
# Return a combined result or just the checkpoint result as needed
os.system("sleep 100")

cmd = f"cat ./MVVM_checkpoint.out ./MVVM_checkpoint.1.out ./MVVM_restore.1.out ./MVVM_restore.out"
cmd = cmd.split()
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
output = result.stdout.decode("utf-8")
except:
output = result.stdout

exec = " ".join([env] + [aot_file] + arg)
res.append((exec, output))
return res



def run_slowtier(
aot_file: str, arg: list[str], env: str, extra: str = ""
) -> tuple[str, str]:
Expand Down
Binary file added artifact/result/optimistic.pdf
Binary file not shown.
10 changes: 6 additions & 4 deletions artifact/run_with_cpu_monitoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ while true; do
if [ "$line" == "" ]; then
break
fi
echo $line >>$1.energy.out
date >> $1.ps.out
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.energy.out
date >> $1.ps.out
echo $line >>$1.ps.out
done
sleep 0.005
if ! ps -p $pid >/dev/null; then
sleep 0.01
if ! ps -p $pid1 >/dev/null; then
sleep 0.5
fi
done
18 changes: 18 additions & 0 deletions artifact/run_with_cpu_monitoring_nocommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
echo "$@"
pid1=`ps aux | grep $1 | grep -v grep | awk '{print $2}'|tail -n 1`
echo $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
date >> $1.ps.out
echo $line >>$1.ps.out
sleep 0.01
if ! ps -p $pid1 >/dev/null; then
sleep 0.5
fi
done
14 changes: 8 additions & 6 deletions artifact/run_with_energy_monitoring.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#!/bin/bash
echo "$@"
pcm-power 1 -m -1 -- "$@" &> $1.out &
pid1=$!
pid1=`ps aux | grep $1 | grep -v grep | awk '{print $2}'|tail -n 1`
# 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
pcm-power 1 -m -1 &> $1.$2.energy.out &
pid2=$!
while true; do
line=$(ps auxh -q $pid1)
if [ "$line" == "" ]; then
break
fi
echo $line >>$1.ps.out
date >> $1.$2.ps.out
echo $line >> $1.$2.ps.out
for child in $(pgrep -P $pid1); do
line=$(ps auxh -q $child)
if [ "$line" == "" ]; then
continue
fi
echo $line >>$1.ps.out
date >> $1.$2.ps.out
echo $line >> $1.$2.ps.out
done
sleep 0.005
if ! ps -p $pid >/dev/null; then
sleep 0.01
if ! ps -p $pid1 >/dev/null; then
sleep 0.5
sudo kill -9 $pid2
fi
Expand Down
15 changes: 8 additions & 7 deletions artifact/run_with_energy_monitoring_mac.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#!/bin/bash
echo "$@"
"$@" &> $1.out &
pid1=$!
pid1=`ps aux | grep $1 | grep -v grep | awk '{print $2}'|tail -n 1`
# 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 &
sudo asitop --show_cores &> $1.$2.energy.out &
pid2=$!
while true; do
line=$(ps auxh -q $pid1)
if [ "$line" == "" ]; then
break
fi
echo $line >>$1.ps.out
date >> $1.$2.ps.out
echo $line >> $1.$2.ps.out
for child in $(pgrep -P $pid1); do
line=$(ps auxh -q $child)
if [ "$line" == "" ]; then
continue
fi
echo $line >>$1.ps.out
date >> $1.$2.ps.out
echo $line >> $1.$2.ps.out
done
sleep 0.005
if ! ps -p $pid >/dev/null; then
sleep 0.01
if ! ps -p $pid1 >/dev/null; then
sleep 0.5
sudo kill -9 $pid2
fi
Expand Down
Loading

0 comments on commit 1c49a37

Please sign in to comment.