Graviola, fix RAPL, shutdown

This commit is contained in:
Pascal Engélibert 2026-01-21 09:20:02 +01:00
commit ac56eb5b82
3 changed files with 55 additions and 24 deletions

72
exp.py
View file

@ -184,8 +184,8 @@ CONFIGS = {
"i5": {
"experiments": [
"impl-cipher-ver",
"impl-cert-ver",
"impl-kex-ver",
#"impl-cert-ver",
#"impl-kex-ver",
],
"setups": [
"none",
@ -193,7 +193,7 @@ CONFIGS = {
"server",
],
"records": [
{ "filename": "wikipedia", "repeat": 100 },
{ "filename": "wikipedia", "repeat": 500 },
],
"repodir": "/home/tuxmain/reps/tlsbench",
"expdir": "/dev/shm/exp",
@ -209,7 +209,7 @@ CONFIGS = {
"p3_suffix": "",
"p3_port_plain": 80,
"p3_port_tls": 443,
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 0 -",
"idle": "idle - - - - - - - 600.000194311142 0.0 1822 6541 1.3880000000000052 304283035 -",
},
"i5-local": {
"experiments": [
@ -223,7 +223,7 @@ CONFIGS = {
"server-local",
],
"records": [
{ "filename": "wikipedia", "repeat": 10 },
{ "filename": "wikipedia", "repeat": 100 },
],
"repodir": "/home/exp/exp",
"expdir": "/dev/shm/exp",
@ -301,11 +301,11 @@ CERT_SIGN_ALGS = [
]
IMPLS = [
"aws_lc", # Amazon's Rust crypto widely used in Rust stuff
"boring", # Google's fork of OpenSSL used in Chrome and Android
"graviola", # New crypto in Rust
"openssl", # widely used
"ring", # used in most Rust stuff
"symcrypt", # Microsoft's crypto
#"boring", # Google's fork of OpenSSL used in Chrome and Android
#"graviola", # New crypto in Rust
#"openssl", # widely used
#"ring", # used in most Rust stuff
#"symcrypt", # Microsoft's crypto
#"wolfcrypt" # used in embedded (won't build with rpxy for now)
]
# Symmetric ciphers
@ -421,6 +421,10 @@ def alg_filter(kex, cert, cipher, impl):
return False
if cert == "secp384r1" and impl == "boring":
return False
if kex == "SECP256R1MLKEM768" and impl == "graviola":
return False
if kex == "MLKEM768" and impl == "graviola":
return False
return True
DOMAINS = []
@ -688,7 +692,7 @@ def run_netreplay(expdir, repodir, record, p2_addr, p2_port, listen_port, tls_mo
if expdir[-1] != "/":
expdir += "/"
repodir = repodir.removesuffix("/")
env = {"RUST_LOG": "warning", "EARLYDATA": earlydata}
env = {"RUST_LOG": "warning", "SSLKEYLOGFILE": "/dev/shm/netreplay.keys.txt", "EARLYDATA": earlydata}
if ciphers:
env["CIPHERS"] = ciphers
if kexes:
@ -741,8 +745,8 @@ def get_net_stat(ssh):
bytes_out = int(items[8])
return (bytes_in, bytes_out)
def get_rapl_energy(ssh, expdir):
res = ssh_run(ssh, expdir+"/powercap", hide=True)
def get_rapl_energy(ssh, repodir):
res = ssh_run(ssh, repodir+"/powercap", hide=True)
items = res.split("\n")
energy = 0
for item in items:
@ -750,7 +754,7 @@ def get_rapl_energy(ssh, expdir):
energy += int(item)
return energy
def run_exp(config, only_record=None, idle=False):
def run_exp(config, only_record=None, idle=False, shutdown=False):
ssh = None
if "p2_ssh" in config:
ssh = connect_ssh(config)
@ -794,11 +798,11 @@ def run_exp(config, only_record=None, idle=False):
rpxy_cpu = get_cpu_stat(ssh)
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
energy = 0
energy_rapl
energy_rapl = 0
if config["wattmeter"]:
energy = wattmeter.get_meter()
if config["rapl"]:
energy_rapl = get_rapl_energy(ssh)
energy_rapl = get_rapl_energy(ssh, p2_path)
start = time.time()
time.sleep(600)
@ -809,7 +813,7 @@ def run_exp(config, only_record=None, idle=False):
if config["wattmeter"]:
new_energy = wattmeter.get_meter()
if config["rapl"]:
new_energy_rapl = get_rapl_energy(ssh)
new_energy_rapl = get_rapl_energy(ssh, p2_path)
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
new_rpxy_cpu = get_cpu_stat(ssh)
rpxy_cpu_diff = new_rpxy_cpu - rpxy_cpu
@ -880,7 +884,7 @@ def run_exp(config, only_record=None, idle=False):
if config["wattmeter"]:
energy = wattmeter.get_meter()
if config["rapl"]:
energy_rapl = get_rapl_energy(ssh)
energy_rapl = get_rapl_energy(ssh, p2_path)
start = time.time()
netreplay = run_netreplay(
@ -915,7 +919,7 @@ def run_exp(config, only_record=None, idle=False):
#time.sleep(30)
#sh("killall netreplay")
try:
#ssh_run(ssh, f"rm /dev/shm/access.log /dev/shm/rpxy.log")
ssh_run(ssh, f"rm /dev/shm/access.log /dev/shm/rpxy.log")
pass
except invoke.exceptions.UnexpectedExit as e:
pass
@ -934,7 +938,7 @@ def run_exp(config, only_record=None, idle=False):
if config["wattmeter"]:
new_energy = wattmeter.get_meter()
if config["rapl"]:
new_energy_rapl = get_rapl_energy(ssh)
new_energy_rapl = get_rapl_energy(ssh, p2_path)
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
new_rpxy_cpu = get_cpu_stat(ssh)
record_filename = record["filename"]
@ -957,6 +961,8 @@ def run_exp(config, only_record=None, idle=False):
first_set = False
if config["wattmeter"]:
YAPI.FreeAPI()
if shutdown and ssh:
ssh_run(ssh, f"python3 {p2_path}/exp.py --shutdown")
def update_certs(config):
info = platform.freedesktop_os_release()
@ -1007,6 +1013,7 @@ if __name__ == "__main__":
send <config> Send configs and certs to p2
update-certs <config> Update system's certs
run <config> Run experiment
shutdown Shutdown the system
Make options:
-c Make CA cert (otherwise use already existing one)
@ -1024,6 +1031,7 @@ Run options:
--count Do not run experiments but display number of experiments
--record <id> Only play this record
--idle Also measure when idle
--shutdown Shutdown host and target when finished
""".format(
sig_algs = " ".join(CERT_SIGN_ALGS),
configs = " ".join([i for i in CONFIGS]),
@ -1073,7 +1081,29 @@ Run options:
from yoctopuce.yocto_api import *
from yoctopuce.yocto_power import *
run_exp(config, only_record=getargv("--record", None), idle="--idle" in sys.argv)
bus = None
bus_proxy = None
shutdown = "--shutdown" in sys.argv
if shutdown:
from pydbus import SystemBus
bus = SystemBus()
bus_proxy = bus.get('org.freedesktop.login1', '/org/freedesktop/login1')
if bus_proxy.CanPowerOff() != 'yes':
print("Cannot power off")
exit(1)
run_exp(config, only_record=getargv("--record", None), idle="--idle" in sys.argv, shutdown=shutdown)
if shutdown:
bus_proxy.PowerOff(False)
elif opt == "shutdown":
from pydbus import SystemBus
bus = SystemBus()
bus_proxy = bus.get('org.freedesktop.login1', '/org/freedesktop/login1')
if bus_proxy.CanPowerOff() != 'yes':
print("Cannot power off")
exit(1)
bus_proxy.PowerOff(False)
else:
print("Unknown command, use help for help")
exit(1)