numam/scripts/dpdk.py
2022-11-22 16:27:27 +01:00

230 lines
7.2 KiB
Python
Executable File

from cgi import test
from site import abs_paths
import subprocess as sp
import time
import select
import os
import datetime
import pwd
import sys
import getopt
import numpy as np
import re
import libpar as par
import libtc as tc
import libmechspec as mechspec
import netexp
only_max_qps = True
# [[counter names], counting mode (0 = sampling, 1 = counting)]
pmc_counters = [
"",
# [["mem_load_l3_miss_retired.local_dram"], 1],
# [["mem_load_l3_miss_retired.remote_dram"], 1],
# [["mem_load_l3_miss_retired.remote_hitm"], 1],
# [["mem_load_l3_miss_retired.remote_fwd"], 1]
# [["mem_trans_retired.load_latency_gt_8"], 0],
# [["mem_trans_retired.load_latency_gt_16"], 0],
# [["mem_trans_retired.load_latency_gt_32"], 0],
# [["mem_trans_retired.load_latency_gt_64"], 0],
# [["mem_trans_retired.load_latency_gt_128"], 0],
# [["mem_trans_retired.load_latency_gt_256"], 0],
# [["mem_trans_retired.load_latency_gt_512"], 0],
#[["mem_trans_retired.load_latency_gt_8", ""], 0],
]
# pkt_pad
clt_pkt_pads = [
0,
# 256,
# 512,
# 1024,
# 2048,
# 4096,
# 8192
]
clt_pkt_pads_depth = {}
clt_pkt_pads_depth[0] = 8
clt_pkt_pads_depth[256] = 6
clt_pkt_pads_depth[512] = 6
clt_pkt_pads_depth[1024] = 4
clt_pkt_pads_depth[1518] = 4
clt_pkt_pads_depth[2048] = 2
clt_pkt_pads_depth[4096] = 2
clt_pkt_pads_depth[8192] = 1
clt_pkt_pads_depth[9018] = 1
# clt_load
clt_wrkld = [
[0, "fixed:0", "fixed:0"],
# [0, "uniform:1000", "fixed:0"],
# [0, "uniform:100", "fixed:0"],
# [0, "uniform:10", "fixed:0"],
# [1, "uniform:480", "uniform:1024"],
# [1, "uniform:480", "uniform:256"],
# [1, "uniform:480", "uniform:64"]
]
# paths
file_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.join(file_dir,"..")
# [srv_affinity, OPTIONAL( memgen_affinity, iteration, buffer_size, target_dom )]
server_affinity = [
["1,3,5,7,9,11,13,15,17,19,21,23"],
["25,27,29,31,33,35,37,39,41,43,45,47"],
#["1,3,5,7,9,11,13,15,17,19,21,23", "26,28,30,32,34,36,38,40,42,44,46", -1, 512*1024*1024, 0],
#["25,27,29,31,33,35,37,39,41,43,45,47", "2,4,6,8,10,12,14,16,18,20,22", -1, 512*1024*1024, 1],
# "65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127",
# "1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63",
# "1,3,5,7,9,11,13,15",
# "17,19,21,23,25,27,29,31",
# "33,35,37,39,41,43,45,47",
# "49,51,53,55,57,59,61,63"
]
def flush_netresult(conf : netexp.NetExpConf, result : netexp.NetExpResult):
sample_out = tc.get_odir() + "/" + str(result.parser.qps) + ".txt"
with open(sample_out, "w") as f:
f.write(result.sample)
if conf.enable_pmc:
pmc_out = tc.get_odir() + "/" + str(result.parser.qps) + ".pmc"
if conf.pmc_mode != 0:
with open(pmc_out, "w") as f:
f.write(result.pmc_parser.raw)
else:
with open(pmc_out, "wb") as f:
f.write(result.pmc_parser[0])
with open(pmc_out + "_parsed", "w") as g:
g.write(result.pmc_parser[1])
tc.log_print("=== Summary - qps: " + str(result.parser.qps) + " master loss: " + str(float(result.parser.master_loss) / float(result.parser.master_recv + result.parser.master_loss) * 100.00) + "% slave loss: " + str(float(result.parser.slave_loss) / float(result.parser.slave_recv + result.parser.slave_loss) * 100.0) + "%" )
tc.log_print("=== Server HW:")
tc.log_print(par.mutilate_data.build_mut_output(result.parser.srv_hwlat, [result.parser.qps]) + "\n")
tc.log_print("=== Server SW:")
tc.log_print(par.mutilate_data.build_mut_output(result.parser.srv_swlat, [result.parser.qps]) + "\n")
tc.log_print("=== Client HW:")
tc.log_print(par.mutilate_data.build_mut_output(result.parser.clt_hwlat, [result.parser.qps]) + "\n")
tc.log_print("=== Client SW:")
tc.log_print(par.mutilate_data.build_mut_output(result.parser.clt_swlat, [result.parser.qps]) + "\n")
if conf.enable_pmc:
if conf.pmc_mode != 0:
tc.log_print("=== PMC:")
tc.log_print("counter: " + result.pmc_parser.counter + " count: " + str(result.pmc_parser.count) + " cores: " + str(result.pmc_parser.cores))
def main():
tc.set_ssh_param("-o StrictHostKeyChecking=no -p77")
tc.set_ssh_user("oscar")
output_dirname = "run"
conf = netexp.NetExpConf()
conf.srv_mechspec = mechspec.LAB.SKYLAKE1_10G
conf.clt_mechspecs = [mechspec.LAB.SKYLAKE3_10G, mechspec.LAB.SKYLAKE5_10G]
conf.mst_mechspec = mechspec.LAB.SKYLAKE2_10G
conf.finalize_mechspecs()
conf.root_dir = "/numam.d/build/bin"
# server fixed configs
conf.srv_port = 0
# client fixed configs
conf.clt_ia = "exponential"
conf.clt_affinity = "1,3,5,7,9,11,13,15,17,19,21,23"
conf.clt_port = 0
conf.clt_pkt_loss_lat = 5000
conf.clt_rage_quit_lat = 5000
# master fixed configs
conf.mst_port = 0
conf.mst_warmup = 5
conf.mst_duration = 20
conf.mst_qps = 100
conf.mst_ia = "exponential"
conf.mst_pkt_loss_lat = 5000
conf.mst_pkt_loss_max = 100
conf.mst_affinity = "2"
# pmc stuff
conf.pmc_sampling_rate = 4096
conf.pmc_counting_interval = 0.1
options = getopt.getopt(sys.argv[1:], 'scSD')[0]
for opt, arg in options:
if opt in ('-s'):
netexp.stop_all(conf)
return
elif opt in ('-c'):
conf.enable_client_only=True
elif opt in ('-S'):
netexp.setup(conf, bench = True, dpdk = False)
return
elif opt in ('-D'):
netexp.setup(conf, bench=False, dpdk=True)
return
tc.init("~/results.d/numam_neo/" + output_dirname + "_" + datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
cpcmd = "cp " + __file__ + " " + tc.get_odir() + "/"
tc.log_print(cpcmd)
sp.check_call(cpcmd, shell=True)
for eaff in server_affinity:
conf.srv_affinity = eaff[0]
conf.enable_memgen = False
if len(eaff) > 1:
conf.enable_memgen = True
conf.memgen_affinity = eaff[1]
conf.memgen_iteration = eaff[2]
conf.memgen_size = eaff[3]
conf.memgen_tgtdom = eaff[4]
for epad in clt_pkt_pads:
conf.clt_pkt_pad = 0
conf.clt_pkt_depth = clt_pkt_pads_depth[conf.clt_pkt_pad]
for eload in clt_wrkld:
conf.clt_wrkld = eload[0]
conf.clt_wrkarg0 = eload[1]
conf.clt_wrkarg1 = eload[2]
for epmc in pmc_counters:
conf.enable_pmc = False
if len(epmc) > 0:
conf.enable_pmc = True
conf.pmc_counters = epmc[0]
conf.pmc_mode = epmc[1]
test_name = "affinity" + eaff[0] + "_pad" + str(epad) + "_load" + str(eload[0]) + "," + str(eload[1]) + "," + str(eload[2])
if (conf.enable_memgen):
test_name += "_memload" + str(eaff[1]) + "," + str(eaff[2]) + "," + str(eaff[3]) + "," + str(eaff[4])
if (conf.enable_pmc):
test_name += "_pmc" + str(epmc[1]) + "_" + conf.get_pmc_str()
tc.begin(test_name)
conf.clt_qps = 0
tc.log_print("============ " + test_name + " QPS: MAX ============")
result : netexp.NetExpResult = netexp.run(conf)
flush_netresult(conf, result)
max_qps = result.parser.qps
if conf.enable_client_only:
return
if only_max_qps:
continue
finish = (int)(max_qps - max(conf.mst_qps, 0.01 * max_qps))
step = (int)(finish / 10)
cur_qps = step
while cur_qps <= finish:
tc.log_print("============ " + test_name + " QPS: " + str(cur_qps) + " ============")
conf.clt_qps = cur_qps
result : netexp.NetExpResult = netexp.run(conf)
flush_netresult(result)
cur_qps += step
tc.log_print("")
tc.end()
netexp.stop_all(conf)
main()