Constant time
This commit is contained in:
parent
3ef86c3593
commit
7ae94371a8
5 changed files with 81 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,5 +2,4 @@
|
|||
netreplay*
|
||||
powercap
|
||||
__pycache__
|
||||
rpxy_*
|
||||
records/
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ Install OpenSSL with debug symbols:
|
|||
/usr/bin/perl ./Configure --release -g --prefix=/usr --openssldir=/usr/lib/ssl --libdir=lib/x86_64-linux-gnu shared no-idea no-mdc2 no-rc5 no-ssl3 no-ssl3-method enable-rfc3779 enable-cms no-capieng no-rdrand enable-zlib enable-ec_nistp_64_gcc_128 linux-x86_64
|
||||
```
|
||||
|
||||
To build rpxy with this openssl:
|
||||
To build netreplay with this openssl:
|
||||
|
||||
```bash
|
||||
OPENSSL_LIB_DIR=/home/pi/reps/openssl-openssl-3.6.0/ OPENSSL_DIR=/home/pi/reps/openssl-openssl-3.6.0/ cargo build --release
|
||||
|
|
|
|||
36
exp.py
36
exp.py
|
|
@ -87,7 +87,7 @@ CONFIGS = {
|
|||
True,
|
||||
],
|
||||
"records": [
|
||||
{ "filename": "wikipedia", "repeat": 1000 },
|
||||
{ "filename": "wikipedia", "repeat": 10000, "time": 90 },
|
||||
],
|
||||
"repo_dir": "/home/tuxmain/reps/tlsbench",
|
||||
"exp_dir": "/dev/shm/exp",
|
||||
|
|
@ -102,7 +102,7 @@ CONFIGS = {
|
|||
"rapl": False,
|
||||
"sa": True,
|
||||
"listen_port": 8080,
|
||||
"idle": "idle - - - - - - - - - 600.000081539154 0.0 896 4792 0.5399999999999991 0 -",
|
||||
"idle": "idle - - - - - - - - - - - 600.000081539154 0.0 896 4792 0.5399999999999991 0 -",
|
||||
"notify_listen": ("0.0.0.0", 8090),
|
||||
"notify_addr": "192.168.3.1:8090",
|
||||
},
|
||||
|
|
@ -245,10 +245,11 @@ CONFIGS = {
|
|||
},
|
||||
"g5k": {
|
||||
"experiments": [
|
||||
"impl-cipher-ver",
|
||||
"impl-cert-ver",
|
||||
"impl-kex-ver",
|
||||
"zrtt",
|
||||
#"impl-cipher-ver",
|
||||
#"impl-cert-ver",
|
||||
#"impl-kex-ver",
|
||||
#"zrtt",
|
||||
"realistic",
|
||||
],
|
||||
"sides": [
|
||||
"client",
|
||||
|
|
@ -259,7 +260,7 @@ CONFIGS = {
|
|||
True,
|
||||
],
|
||||
"records": [
|
||||
{ "filename": "wikipedia", "repeat": 12000 },
|
||||
{ "filename": "wikipedia", "repeat": 12000, "time": 60 },
|
||||
],
|
||||
"repo_dir": "/home/pengelib/tlsbench",
|
||||
"exp_dir": "/dev/shm/exp",
|
||||
|
|
@ -638,7 +639,9 @@ def run_netreplay_client(ssh, exp_dir, repo_dir, record, remote_addr, remote_por
|
|||
env["CIPHERS"] = ciphers
|
||||
if kexes:
|
||||
env["KEXES"] = kexes
|
||||
cmd = [repo_dir+"/netreplay"+("" if impl == None else ("-"+impl)), repo_dir+"/records/"+record["filename"], "client", remote_addr, str(remote_port), "-r", str(record["repeat"]), "--certs", certs_dir]
|
||||
cmd = [repo_dir+"/netreplay"+("" if impl == None else ("-"+impl)), repo_dir+"/records/"+record["filename"], "client", remote_addr, str(remote_port), "--certs", certs_dir]
|
||||
if "repeat" in record:
|
||||
cmd += ["-r", str(record["repeat"])]
|
||||
if debug:
|
||||
cmd.append("-d")
|
||||
if tls:
|
||||
|
|
@ -911,7 +914,7 @@ def run_exp(config, only_record=None, idle=False, shutdown=False, debug=False):
|
|||
# Measure
|
||||
cpu = 0
|
||||
if config["sa"]:
|
||||
cpu = get_cpu_stat(ssh, ["netreplay-"+impl, "tokio-runtime-w"])
|
||||
cpu = get_cpu_stat(ssh, ["netreplay-"+impl, "tokio-runtime-w", "tokio-rt-worker"])
|
||||
remote_bytes_in, remote_bytes_out = get_net_stat(ssh)
|
||||
energy = 0
|
||||
energy_rapl = 0
|
||||
|
|
@ -922,9 +925,15 @@ def run_exp(config, only_record=None, idle=False, shutdown=False, debug=False):
|
|||
start = time.time()
|
||||
|
||||
# Wait for the client to terminate
|
||||
signal.alarm(3600)
|
||||
signal.alarm(record["time"] if "time" in record else 3600)
|
||||
session_count = 0
|
||||
try:
|
||||
notify_socket.recv(4)
|
||||
while True:
|
||||
rec_count = int.from_bytes(notify_socket.recv(4))
|
||||
if rec_count == 0xffffffff:
|
||||
break
|
||||
if rec_count > session_count:
|
||||
session_count = rec_count
|
||||
except Timeout:
|
||||
print("TIMEOUT: stop")
|
||||
|
||||
|
|
@ -953,7 +962,7 @@ def run_exp(config, only_record=None, idle=False, shutdown=False, debug=False):
|
|||
# Measure CPU after (as it may update only after the process is killed)
|
||||
new_cpu = 0
|
||||
if config["sa"]:
|
||||
new_cpu = get_cpu_stat(ssh, ["netreplay-"+impl, "tokio-runtime-w"])
|
||||
new_cpu = get_cpu_stat(ssh, ["netreplay-"+impl, "tokio-runtime-w", "tokio-rt-worker"])
|
||||
|
||||
record_filename = record["filename"]
|
||||
cpu_diff = new_cpu - cpu
|
||||
|
|
@ -962,11 +971,10 @@ def run_exp(config, only_record=None, idle=False, shutdown=False, debug=False):
|
|||
energy_diff = new_energy - energy
|
||||
energy_rapl_diff = new_energy_rapl - energy_rapl
|
||||
time_diff = end - start
|
||||
repeats = record["repeat"]
|
||||
while True:
|
||||
try:
|
||||
with open(logfile_path, "a") as logfile:
|
||||
logfile.write(f"{expname} {impl} {alg} {kex} {cipher} {earlydata} {side} {tls_int} {record_filename} {repeats} {start} {end} {time_diff} {cpu_diff} {remote_bytes_in_diff} {remote_bytes_out_diff} {energy_diff} {energy_rapl_diff} {prof_filename}\n")
|
||||
logfile.write(f"{expname} {impl} {alg} {kex} {cipher} {earlydata} {side} {tls_int} {record_filename} {session_count} {start} {end} {time_diff} {cpu_diff} {remote_bytes_in_diff} {remote_bytes_out_diff} {energy_diff} {energy_rapl_diff} {prof_filename}\n")
|
||||
logfile.close()
|
||||
break
|
||||
except Exception as e:
|
||||
|
|
|
|||
58
plots.py
58
plots.py
|
|
@ -483,6 +483,62 @@ def cmp_versions(logs, exps, criteria, objs):
|
|||
except ZeroDivisionError:
|
||||
pass
|
||||
|
||||
def tabulate(lines):
|
||||
widths = [0] * len(lines[0])
|
||||
for line in lines:
|
||||
for col in range(len(line)):
|
||||
if len(line[col]) > widths[col]:
|
||||
widths[col] = len(line[col])
|
||||
table = ""
|
||||
for line in lines:
|
||||
for col in range(len(line)):
|
||||
if col > 0:
|
||||
table += " "
|
||||
table += line[col]
|
||||
table += " " * (widths[col] - len(line[col]))
|
||||
table += "\n"
|
||||
return table
|
||||
|
||||
def make_summary(logs):
|
||||
plain_result_key = lambda log: (log["exp"], log["side"])
|
||||
result_key = lambda log: (log["exp"], log["side"], log["impl"], log["alg"], log["kex"], log["cipher"], log["ed"])
|
||||
|
||||
plain_results = {}
|
||||
results = {}
|
||||
idle_val = None
|
||||
|
||||
for log in logs:
|
||||
if log["exp"] == "idle":
|
||||
idle_val = {
|
||||
"cpu": float(log["cpu"]) / float(log["time"]),
|
||||
"energy": float(log["Wh"]) / float(log["time"]) * 3600,
|
||||
}
|
||||
if log["tls"] == "0":
|
||||
n = float(log.get("n", "1000"))
|
||||
plain_results[plain_result_key(log)] = {
|
||||
"cpu": (float(log["cpu"]) - idle_val["cpu"] * float(log["time"])) / n,
|
||||
"energy": (float(log["Wh"]) * 3600 - idle_val["energy"] * float(log["time"])) / n
|
||||
}
|
||||
if log["exp"] != "idle" and log["tls"] == "1":
|
||||
n = float(log.get("n", "1000"))
|
||||
results[result_key(log)] = {
|
||||
"cpu": (float(log["cpu"]) - idle_val["cpu"] * float(log["time"])) / n,
|
||||
"energy": (float(log["Wh"]) * 3600 - idle_val["energy"] * float(log["time"])) / n
|
||||
}
|
||||
|
||||
lines = [["key", "idle (W)", "no_tls (Ws/S)", "tls (Ws/S)", "tls_only (1)"]]
|
||||
for k in results:
|
||||
no_tls = plain_results[k[:2]]["energy"]
|
||||
tls = results[k]["energy"]
|
||||
lines.append([
|
||||
"/".join([str(i) for i in k]),
|
||||
str(idle_val["energy"]),
|
||||
str(no_tls),
|
||||
str(tls),
|
||||
str((tls - no_tls) / tls),
|
||||
])
|
||||
print(tabulate(lines))
|
||||
|
||||
def getargv(arg:str, default="", n:int=1, args:list=sys.argv):
|
||||
if arg in args and len(args) > args.index(arg)+n:
|
||||
return args[args.index(arg)+n]
|
||||
|
|
@ -537,6 +593,8 @@ if __name__ == "__main__":
|
|||
make_profile_plot_grouped(logs, "impl-cipher-ver", "cipher", side, record, "impl", no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
make_profile_plot_grouped(logs, "impl-cert-ver", "cert", side, record, "impl", no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
make_profile_plot_grouped(logs, "impl-kex-ver", "kex", side, record, "impl", no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
elif cmd == "summary":
|
||||
make_summary(logs)
|
||||
elif cmd == "correl":
|
||||
from scipy import stats
|
||||
import matplotlib.pyplot as plt
|
||||
|
|
|
|||
8
run.sh
8
run.sh
|
|
@ -1,8 +0,0 @@
|
|||
#kissdns kissdns.json 5532
|
||||
RUST_LOG=debug ./rpxy_rustls_ring --config experiments/p1_tls.toml &
|
||||
RUST_LOG=debug ./rpxy_rustls_ring --config experiments/p2_tls.toml &
|
||||
RUST_LOG=debug ./rpxy_rustls_ring --config experiments/p3.toml &
|
||||
|
||||
# By default, ^C does not kill subprocesses. This fixes it.
|
||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||
wait
|
||||
Loading…
Add table
Add a link
Reference in a new issue