if args.transparent: print('--- running in transparent mode ---') sys.stdout.flush() env.chdir_to_root() config_path = os.path.normpath( os.path.join('configs', args.sys_config_to_use)) click_path = os.path.normpath( os.path.join('configs', conf_name)) main_cmdargs = ['bin/main'] + env.mangle_main_args( config_path, click_path, emulate_opts=emulate_opts) retcode = loop.run_until_complete( execute_async_simple(main_cmdargs, timeout=args.timeout)) else: retcode = loop.run_until_complete( env.execute_main(args.sys_config_to_use, conf_name, running_time=32.0, emulate_opts=emulate_opts)) if retcode not in (0, -signal.SIGTERM, -signal.SIGKILL): print( 'The main program exited abnormaly, and we ignore the results! (exit code: {0})' .format(retcode)) continue if args.transparent: continue # Fetch results of throughput measurement and compute average. num_nodes = env.get_num_nodes() thruput_records = thruput_reader.get_records() avg_thruput_mpps, avg_thruput_gbps = 0.0, 0.0 for node_id in range(num_nodes):
emulate_opts = {'--emulated-pktsize': pktsize} else: emulate_opts = None for pktgen in pktgens: pktgen.set_args("-i", "all", "-f", "0", "-v", "4", "-p", str(pktsize)) # Configure what and how to measure things. thruput_records = env.measure_thruput(begin_after=15.0, repeat=True) cpu_records = env.measure_cpu_usage(interval=1.2, begin_after=15.0, repeat=True) # Run. with ExitStack() as stack: # TODO: Implement running pktgen server remotely #_ = [stack.enter_context(pktgen) for pktgen in pktgens] loop = asyncio.get_event_loop() retcode = loop.run_until_complete(env.execute_main(args.sys_config_to_use, args.element_config_to_use, running_time=30.0, emulate_opts=emulate_opts)) if retcode != 0: print('The main program exited abnormaly, and we ignore the results! (exit code: {0})'.format(retcode)) continue # Fetch results of throughput measurement and compute average. average_thruput_mpps = mean(t.total_fwd_pps for t in thruput_records) average_thruput_gbps = mean(t.total_fwd_bps for t in thruput_records) print('{0:6.2f}'.format(average_thruput_mpps), end=' ') print('{0:6.2f}'.format(average_thruput_gbps), end=' ') # Fetch results of cpu util measurement and compute average. io_usr_avg = io_sys_avg = coproc_usr_avg = coproc_sys_avg = 0 io_usr_avgs = []; io_sys_avgs = []; coproc_usr_avgs = []; coproc_sys_avgs = [] io_cores = env.get_io_cores() coproc_cores = env.get_coproc_cores()
high_branch = 100 - branch_ratio_local low_branch = branch_ratio_local # Generate Click config from a template click_path = os.path.normpath(os.path.join('configs', branch_config)) temp_file = tempfile.NamedTemporaryFile('w', prefix='nba.temp.click.', delete=False) with open(click_path, 'r') as infile, temp_file as outfile: data_in = infile.read() data_out = data_in.format(str(high_branch), str(low_branch), 'echoback'); print(data_out, file=outfile) # Run. with ExitStack() as stack: _ = [stack.enter_context(pktgen) for pktgen in pktgens] loop = asyncio.get_event_loop() loop.run_until_complete(env.execute_main('default.py', temp_file.name, running_time=31.0)) # Delete the generated config. os.unlink(temp_file.name) # Retrieve the results. print('{0:5} {1:5} {2:5} {3:5} {4:5} {5:5}'.format(*params), end=' ') # Fetch results of throughput measurement and compute average. average_thruput_mpps = mean(t.total_fwd_pps for t in thruput_fetcher) average_thruput_gbps = mean(t.total_fwd_bps for t in thruput_fetcher) print('{0:6.2f}'.format(average_thruput_mpps), end=' ') print('{0:6.2f}'.format(average_thruput_gbps), end=' ') print() # Check max result.
emulate_opts = {'--emulated-pktsize': pktsize} else: emulate_opts = None for pktgen in pktgens: pktgen.set_args("-i", "all", "-f", "0", "-v", "4", "-p", str(pktsize)) # Clear data. env.reset_readers() # Run. with ExitStack() as stack: _ = [stack.enter_context(pktgen) for pktgen in pktgens] retcode = loop.run_until_complete( env.execute_main(args.sys_config_to_use, args.element_config_to_use, running_time=0, emulate_opts=emulate_opts)) if retcode not in (0, -signal.SIGTERM, -signal.SIGKILL): print( 'The main program exited abnormaly, and we ignore the results! (exit code: {0})' .format(retcode)) #records[0].append(PPCRecord(10, 12, 10, 0.5, 25.5)) #records[0].append(PPCRecord(11, 13, 12, 0.6, 23.5)) #records[0].append(PPCRecord(10, 10, 13, 0.5, 22.5)) #records[0].append(PPCRecord(11, 9, 15, 0.4, 28.5)) #records[0].append(PPCRecord(11, 12, 16, 0.3, 29.5)) #records[1].append(PPCRecord(13, 10, 9, 0.3, 25.5)) #records[1].append(PPCRecord(14, 15, 15, 0.25, 24.8)) #records[1].append(PPCRecord(15, 11, 13, 0.4, 24.2)) #records[1].append(PPCRecord(12, 12, 12, 0.48, 28.8))
marcel.set_args("-i", "xge0", "-f", "0,", "-v", "4", "-p", psize, "-g", speed_local, "-l", "1") with marcel: # Generate pipeline config. unit = "None() -> " end_config = "L2Forward(method echoback) -> ToOutput();" for i in range(branch_lv_count): end_config = unit + end_config temp_path = os.path.normpath(os.path.join('configs', "__temp.click")) outfile = open(temp_path, "w") outfile.write(end_config) outfile.close() # Run. loop = asyncio.get_event_loop() loop.run_until_complete(env.execute_main('single-port-multi-cpu.py', "__temp.click", running_time=20.0)) # Retrieve the results. print('{0:5} {1:5} {2:5} {3:5} {4:5} {5:5} pkt{6:6} count{7:7} {8:8}Gbps'.format(params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8]), end=' ') for thruput in thruput_fetcher: print('delay: {0:10}'.format(marcel.get_delay()), end=' ') print('totalpkt: {0:10}'.format(thruput.total_fwd_pps), end=' ') print('totaldrop: {0:10}'.format(thruput.total_in_errs), end=' ') io_cores = env.get_io_cores(8) comp_cores = env.get_comp_cores(8, 'sibling') for cpu_usages in cpu_fetcher: cpu_usage = tuple(filter(lambda o: str(o.core) == str(0), cpu_usages)) if cpu_usage: print('{0:6.2f} {1:6.2f}'.format(cpu_usage[0].usr, cpu_usage[0].sys), end=' ')
thruput_reader.pktsize_hint = pktsize thruput_reader.conf_hint = short_conf_name # Run. with ExitStack() as stack: _ = [stack.enter_context(pktgen) for pktgen in pktgens] if args.transparent: print('--- running in transparent mode ---') sys.stdout.flush() env.chdir_to_root() config_path = os.path.normpath(os.path.join('configs', args.sys_config_to_use)) click_path = os.path.normpath(os.path.join('configs', conf_name)) main_cmdargs = ['bin/main'] + env.mangle_main_args(config_path, click_path, emulate_opts=emulate_opts) retcode = loop.run_until_complete(execute_async_simple(main_cmdargs, timeout=args.timeout)) else: retcode = loop.run_until_complete(env.execute_main(args.sys_config_to_use, conf_name, running_time=32.0, emulate_opts=emulate_opts)) if retcode not in (0, -signal.SIGTERM, -signal.SIGKILL): print('The main program exited abnormaly, and we ignore the results! (exit code: {0})'.format(retcode)) continue if args.transparent: continue # Fetch results of throughput measurement and compute average. num_nodes = env.get_num_nodes() thruput_records = thruput_reader.get_records() avg_thruput_mpps, avg_thruput_gbps = 0.0, 0.0 for node_id in range(num_nodes): mpps = [t.mpps for t in thruput_records if t.node_id == node_id] gbps = [t.gbps for t in thruput_records if t.node_id == node_id] if len(mpps) > 0:
env.envvars['NBA_SINGLE_PORT_MULTI_CPU_NODE'] = str(params[5]) psize = str(params[6]) speed_local = int(params[7]) env.envvars['NBA_COPROC_PPDEPTH'] = str(params[8]) # Configure what and how to measure things. thruput_fetcher = env.measure_thruput(begin_after=15.0, repeat=False) cpu_fetcher = env.measure_cpu_usage(interval=1, begin_after=17.0, repeat=False) ip_version = '6' if 'ipv6' in app_name else '4' marcel.set_args("-i", "all", "-f", "0", "-v", ip_version, "-p", psize, "-g", speed_local, "-l", "1") with marcel: # Run. loop = asyncio.get_event_loop() loop.run_until_complete(env.execute_main('rss.py', "ipv6-router.click", running_time=20.0)) # Retrieve the results. print('{0:5} {1:5} {2:5} {3:5} {4:5} {5:5} pkt {6:6} {7:7}Gbps cppdepth {8:8}'.format(params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8]), end=' ') for thruput in thruput_fetcher: print('delay: {0:10}'.format(marcel.get_delay()), end=' ') print('totalpkt: {0:10}'.format(thruput.total_fwd_pps), end=' ') print('totaldrop: {0:10}'.format(thruput.total_in_errs), end=' ') io_cores = env.get_io_cores(8) comp_cores = env.get_comp_cores(8, 'sibling') for cpu_usages in cpu_fetcher: cpu_usage = tuple(filter(lambda o: str(o.core) == str(0), cpu_usages)) if cpu_usage: print('{0:6.2f} {1:6.2f}'.format(cpu_usage[0].usr, cpu_usage[0].sys), end=' ')
psize = str(params[5]) # Configure what and how to measure things. thruput_fetcher = env.measure_thruput(begin_after=15.0, repeat=False) cpu_fetcher = env.measure_cpu_usage(interval=1, begin_after=17.0, repeat=False) # Make progress of the generators to ensure configuration is applied. next(thruput_fetcher) next(cpu_fetcher) lahti.set_args("-i", "all", "-f", "0,", "-v", "4", "-p", psize) marcel.set_args("-i", "all", "-f", "0,", "-v", "4", "-p", psize) with lahti, marcel: # Run. env.execute_main('single-port-multi-cpu.py', sys.argv[1], running_time=20.0) # Retrieve the results. print('{0:5} {1:5} {2:5} {3:5} {4:5} {5:6}'.format(*params), end=' ') for thruput in thruput_fetcher: print('totalpkt: {0:10,}'.format(thruput.total_fwd_pps), end=' ') io_cores = env.get_io_cores(8) comp_cores = env.get_comp_cores(8, 'same') for cpu_usages in cpu_fetcher: cpu_usage = tuple(filter(lambda o: str(o.core) == str(0), cpu_usages)) if cpu_usage: print('{0:6.2f} {1:6.2f}'.format(cpu_usage[0].usr, cpu_usage[0].sys), end=' ') cpu_usage = tuple(filter(lambda o: str(o.core) == str(16), cpu_usages)) if cpu_usage:
print('Outputs: forwarded-pps cpu-util(usr)-io cpu-util(sys)-io cpu-util(usr)-comp cpu-util(sys)-comp') sys.stdout.flush() env.envvars['NBA_LOADBALANCER_MODE'] = lb_mode for params in product(iobatchsizes, compbatchsizes, compppdepths): #, coprocppdepths): env.envvars['NBA_IO_BATCH_SIZE'] = str(params[0]) env.envvars['NBA_COMP_BATCH_SIZE'] = str(params[1]) env.envvars['NBA_COMP_PPDEPTH'] = str(params[2]) # Configure what and how to measure things. thruput_fetcher = env.measure_thruput(begin_after=15.0, repeat=False) cpu_fetcher = env.measure_cpu_usage(interval=1, begin_after=17.0, repeat=False) # Run. loop = asyncio.get_event_loop() loop.run_until_complete(env.execute_main('rss.py', sys.argv[1], running_time=20.0)) # Retrieve the results. print('{0:5} {1:5} {2:5}'.format(params[0], params[1], params[2]), end=' ') for thruput in thruput_fetcher: print('{0:10,}'.format(thruput.avg_out_pps), end=' ') io_cores = env.get_io_cores(8) comp_cores = env.get_comp_cores(8, 'sibling') for cpu_usage in cpu_fetcher: io_avg = ( sum(cpu_usage[core].usr for core in io_cores) / len(io_cores), sum(cpu_usage[core].sys for core in io_cores) / len(io_cores), ) comp_avg = (
temp_file = tempfile.NamedTemporaryFile('w', prefix='nba.temp.click.', delete=False) with open(click_path, 'r') as infile, temp_file as outfile: data_in = infile.read() data_out = data_in.format(str(high_branch), str(low_branch), 'echoback') print(data_out, file=outfile) # Run. with ExitStack() as stack: _ = [stack.enter_context(pktgen) for pktgen in pktgens] loop = asyncio.get_event_loop() loop.run_until_complete( env.execute_main('default.py', temp_file.name, running_time=31.0)) # Delete the generated config. os.unlink(temp_file.name) # Retrieve the results. print('{0:5} {1:5} {2:5} {3:5} {4:5} {5:5}'.format(*params), end=' ') # Fetch results of throughput measurement and compute average. average_thruput_mpps = mean(t.total_fwd_pps for t in thruput_fetcher) average_thruput_gbps = mean(t.total_fwd_bps for t in thruput_fetcher) print('{0:6.2f}'.format(average_thruput_mpps), end=' ') print('{0:6.2f}'.format(average_thruput_gbps), end=' ') print()
repeat=False) cpu_fetcher = env.measure_cpu_usage(interval=1, begin_after=17.0, repeat=False) # Make progress of the generators to ensure configuration is applied. next(thruput_fetcher) next(cpu_fetcher) lahti.set_args("-i", "all", "-f", "0,", "-v", "4", "-p", psize) marcel.set_args("-i", "all", "-f", "0,", "-v", "4", "-p", psize) with lahti, marcel: # Run. env.execute_main('single-port-multi-cpu.py', sys.argv[1], running_time=20.0) # Retrieve the results. print('{0:5} {1:5} {2:5} {3:5} {4:5} {5:6}'.format(*params), end=' ') for thruput in thruput_fetcher: print('totalpkt: {0:10,}'.format(thruput.total_fwd_pps), end=' ') io_cores = env.get_io_cores(8) comp_cores = env.get_comp_cores(8, 'same') for cpu_usages in cpu_fetcher: cpu_usage = tuple( filter(lambda o: str(o.core) == str(0),