def bench_ix(args, host1, host2): bench_common.deploy(host1, [args.ix + '/dp/ix', args.ix + '/apps/echoserver']) bench_common.deploy(host2, [args.ix + '/dp/ix', args.ix + '/apps/echoclient']) for msg_size in IX_MSG_SIZES: result = 0 try: with bench_common.ProcessManager() as proc_manager: channel, pid = proc_manager.spawn( host1, 'sudo stdbuf -o0 -e0 %(DIR)s/ix -c /etc/ix.conf -- %(DIR)s/echoserver %(msg_size)d 2' % { 'DIR': DIR, 'msg_size': msg_size }, 'sudo kill {pid}') time.sleep(IX_WAIT_TO_BOOT_SECS) bench_common.consume(channel) clients = bench_common.Clients( proc_manager, [host2], 'sudo %(DIR)s/ix -l 0 -c /etc/ix.conf -- %(DIR)s/echoclient %(host)s %(port)d %(msg_size)d' % { 'DIR': DIR, 'host': bench_common.get_host_ip(host1), 'port': IX_PORT, 'msg_size': msg_size }, 'sudo kill {pid}') result = clients.run() finally: print '%d %f' % (msg_size, result)
def bench(server, clients, connections_per_client, port, core_count, ix_channel): kstats_re = re.compile( r'.*non idle cycles=(?P<non_idle_cycles>[0-9]*).*LLC load misses=(?P<llc_load_misses>[0-9]*) \((?P<pkts>[0-9]*) pkts, avg batch=(?P<avg_batch>[0-9]*)' ) if ix_channel is None: duration = 5 else: duration = 15 with bench_common.ProcessManager() as proc_manager: clients_ = bench_common.Clients( proc_manager, clients, 'stdbuf -o0 -e0 /tmp/' + getpass.getuser() + '/client %s %d %d %d %d' % (bench_common.get_host_ip(server), port, connections_per_client, DEF_MSG_SIZE, 999999999), 'kill {pid}', duration=duration) print '%d %d' % (connections_per_client * len(clients), clients_.run()), if ix_channel is None: print else: f = ix_channel.makefile('rb') count = 0 while count < core_count: line = bench_common.readline_retry(f) if 'BEGIN' in line: count += 1 non_idle_cycles = 0 llc_load_misses = 0 pkts = 0 avg_batch = 0 count = 0 llc = [] while count < core_count: line = bench_common.readline_retry(f) if 'BEGIN' in line: count += 1 m = kstats_re.match(line) non_idle_cycles += int(m.group('non_idle_cycles')) llc_load_misses += int(m.group('llc_load_misses')) pkts += int(m.group('pkts')) avg_batch += int(m.group('avg_batch')) if pkts == 0: print '0 0 0' else: print '%f %f %f' % (1.0 * non_idle_cycles / pkts, 1.0 * llc_load_misses / pkts, 1.0 * avg_batch / core_count) while True: try: f.readline() except socket.timeout: break
def main(): parser = argparse.ArgumentParser() parser.add_argument('--target', choices=['linux', 'ix'], required=True) parser.add_argument('--ix') parser.add_argument('--kstats', action='store_true') parser.add_argument('server') parser.add_argument('client', nargs='+') args = parser.parse_args() server = spur.SshShell(args.server, missing_host_key=spur.ssh.MissingHostKey.accept) clients = [] for client_name in args.client: clients.append( spur.SshShell(client_name, missing_host_key=spur.ssh.MissingHostKey.accept)) if args.target == 'linux': server_deploy = ['server'] elif args.target == 'ix': server_deploy = [args.ix + '/dp/ix', args.ix + '/apps/echoserver'] bench_common.deploy(server, server_deploy) for client in clients: bench_common.deploy(client, ['client']) cores = bench_common.get_cores(server) with bench_common.ProcessManager() as proc_manager: if args.target == 'linux': port = LINUX_PORT core_str = ','.join([str(x) for x in cores]) proc_manager.spawn( server, '/tmp/' + getpass.getuser() + '/server %d %s' % (DEF_MSG_SIZE, core_str), 'kill {pid}') elif args.target == 'ix': port = IX_PORT channel, pid = proc_manager.spawn( server, 'sudo stdbuf -o0 -e0 /tmp/' + getpass.getuser() + '/ix -c /etc/ix.conf -- /tmp/' + getpass.getuser() + '/echoserver %d 524288' % DEF_MSG_SIZE, 'sudo kill {pid}', ignore_stdout=True) bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), port) bench_common.consume(channel) i = 1.4 while i <= 5.5: connections_per_client = int(10**i) / len(clients) bench(server, clients, connections_per_client, port, len(cores), channel if args.kstats else None) i += 0.2
def main(): parser = argparse.ArgumentParser() parser.add_argument('--target', choices=['linux', 'ix'], required=True) parser.add_argument('--workload', choices=WORKLOADS.keys(), required=True) parser.add_argument('--mutilate', required=True) parser.add_argument('--memcached', required=True) parser.add_argument('--batch') parser.add_argument('--ix') parser.add_argument('server') parser.add_argument('client', nargs='+') args = parser.parse_args() server = spur.SshShell(args.server, missing_host_key = spur.ssh.MissingHostKey.accept) clients = [] for client_name in args.client: clients.append(spur.SshShell(client_name, missing_host_key = spur.ssh.MissingHostKey.accept)) server_deploy = [args.memcached] if args.target == 'ix': server_deploy.extend([args.ix + '/dp/ix', args.ix + '/cp/ixcp.py']) bench_common.deploy(server, server_deploy) for client in clients: bench_common.deploy(client, [args.mutilate]) server.run(shlex.split('cp /etc/ix.conf '+DIR+'/ix.conf')) if args.batch is not None: server.run(shlex.split("sed -i 's/^batch=.*/batch={0}/' ".format(args.batch)+DIR+"/ix.conf")) with bench_common.ProcessManager() as proc_manager: if args.target == 'linux': port = LINUX_PORT cores = bench_common.get_cores(server) core_count = len(cores) cores = ','.join(cores) numa_node = int(server.run(shlex.split('cat /sys/devices/system/cpu/cpu%s/topology/physical_package_id' % cores[0])).output) proc_manager.spawn(server, 'stdbuf -o0 -e0 numactl -m %(numa_node)d %(DIR)s/memcached -k -Mm 1024 -c 4096 -o hashpower=20 -b 8192 -t %(core_count)d -T %(cores)s' % {'DIR': DIR, 'numa_node': numa_node, 'core_count': core_count, 'cores': cores}, 'kill {pid}') bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), port) elif args.target == 'ix': port = IX_PORT channel, pid = proc_manager.spawn(server, 'sudo stdbuf -o0 -e0 %(DIR)s/ix -c %(DIR)s/ix.conf -- %(DIR)s/memcached -k -Mm 1024 -c 4096 -o hashpower=20' % {'DIR': DIR}, 'sudo kill {pid}') bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), port) bench_common.consume(channel) cmdline = '--server=%s:%d %s --qps-function=%s --report-stats=1 --stop-latency=50:750' % (bench_common.get_host_ip(server), port, WORKLOADS[args.workload], SCAN) mutilate = bench_common.mutilate_benchmark(proc_manager, clients, cmdline, CONNECTIONS, THREADS, RECORDS, DEPTH, LATENCY_CONNECTIONS, LATENCY_QPS, TIME) for line in mutilate: if line is None: break if line[0] not in '01234567890 #': continue print line[:-1]
def bench(target, server, clients, cores, core_count, msg_size, msg_per_conn): result = 0 try: with bench_common.ProcessManager() as proc_manager: if target == 'linux': port = LINUX_PORT core_str = ','.join([str(x) for x in cores[:core_count]]) proc_manager.spawn(server, 'stdbuf -o0 -e0 /tmp/'+getpass.getuser()+'/server %d %s' % (msg_size, core_str), 'kill {pid}') elif target == 'ix': port = IX_PORT channel, pid = proc_manager.spawn(server, 'sudo stdbuf -o0 -e0 /tmp/'+getpass.getuser()+'/ix -c /etc/ix.conf -- /tmp/'+getpass.getuser()+'/echoserver %d' % msg_size, 'sudo kill {pid}') bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), port) proc_manager.run(server, 'sudo sh -c "rm -f /tmp/'+getpass.getuser()+'/block-*.fifo"') proc_manager.run(server, 'sudo /tmp/'+getpass.getuser()+'/ixcp.py --cpus %d' % core_count, cwd = '/tmp/'+getpass.getuser()) bench_common.consume(channel) clients_ = bench_common.Clients(proc_manager, clients, '/tmp/'+getpass.getuser()+'/client %s %d %d %d %d' % (bench_common.get_host_ip(server), port, CONNECTIONS_PER_CLIENT, msg_size, msg_per_conn), 'kill {pid}') result = clients_.run() except Exception, e: print >>sys.stderr, 'Exception: %r' % e
def bench_linux(args, host1, host2): bench_common.deploy(host1, ['NPtcp']) bench_common.deploy(host2, ['NPtcp']) with bench_common.ProcessManager() as proc_manager: proc_manager.spawn( host1, 'stdbuf -o0 -e0 %(DIR)s/NPtcp -r -n 100 -p 0 -l 64 -u 1048576' % {'DIR': DIR}, 'kill {pid}') host2.run(shlex.split('rm -f %(DIR)s/np.out' % {'DIR': DIR})) host2.run(shlex.split( '%(DIR)s/NPtcp -r -n 100 -p 0 -l 64 -u 1048576 -h %(host)s' % { 'DIR': DIR, 'host': bench_common.get_host_ip(host1) }), cwd=DIR) cmd = host2.run(shlex.split('cat %(DIR)s/np.out' % {'DIR': DIR})) for pkt_size, goodput_mbps, _ in [[ float(field) for field in line.split() ] for line in cmd.output.splitlines()]: msg_per_sec = goodput_mbps * 1024 * 1024 / 8 / 2 / pkt_size print '%d %f' % (pkt_size, msg_per_sec)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--ix', required=True) parser.add_argument('--workload', choices=WORKLOADS.keys(), required=True) parser.add_argument('--pattern', choices=PATTERNS.keys(), required=True) parser.add_argument('--with-background-job', action='store_true', dest='background') parser.add_argument('--mutilate', required=True) parser.add_argument('--memcached', required=True) parser.add_argument('--outdir', required=True) parser.add_argument('server') parser.add_argument('client', nargs='+') args = parser.parse_args() if not os.path.exists(args.outdir): os.makedirs(args.outdir) server = spur.SshShell(args.server, missing_host_key=spur.ssh.MissingHostKey.accept) clients = [] for client_name in args.client: clients.append( spur.SshShell(client_name, missing_host_key=spur.ssh.MissingHostKey.accept)) server_deploy = [ args.ix + '/dp/ix', args.ix + '/cp/ixcp.py', args.memcached ] if args.background: server_deploy.append('sha1_bench') bench_common.deploy(server, server_deploy) for client in clients: bench_common.deploy(client, [args.mutilate]) with bench_common.ProcessManager() as proc_manager: channel, pid = proc_manager.spawn( server, 'sudo stdbuf -o0 -e0 %(DIR)s/ix -c /etc/ix.conf -- %(DIR)s/memcached -k -Mm 1024 -c 4096 -o hashpower=20' % {'DIR': DIR}, 'sudo kill {pid}') bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), IX_PORT) bench_common.consume(channel) if args.background: server.run( shlex.split('rm -f %(DIR)s/sha1_bench.control' % {'DIR': DIR})) server.run( shlex.split('mkfifo %(DIR)s/sha1_bench.control' % {'DIR': DIR})) proc, background_pid = proc_manager.spawn( server, 'stdbuf -o0 -e0 %(DIR)s/sha1_bench -T 0 -s 41943040 -c %(DIR)s/sha1_bench.control' % {'DIR': DIR}, 'kill {pid}') proc.settimeout(1) sha1_bench = proc.makefile('rb') server.run(shlex.split('sudo chrt -rap 99 %d' % background_pid)) server.run( shlex.split('sudo sh -c "rm -f %(DIR)s/block-*.fifo"' % {'DIR': DIR})) server.run(shlex.split('sudo %(DIR)s/ixcp.py --cpus 1' % {'DIR': DIR}), cwd=DIR) if args.background: cores = bench_common.get_cores(server) cores = cores[:len(cores) / 2] cores.reverse() cores = ','.join(cores) proc, _ = proc_manager.spawn( server, 'sudo stdbuf -o0 -e0 %(DIR)s/ixcp.py --control back --background-cpus %(cores)s --background-fifo %(DIR)s/sha1_bench.control --background-pid %(background_pid)d' % { 'DIR': DIR, 'cores': cores, 'background_pid': background_pid }, 'sudo kill {pid}', cwd=DIR) proc.settimeout(1) ixcp = proc.makefile('rb') server.run(shlex.split('kill -USR1 %d' % (background_pid, ))) else: proc, _ = proc_manager.spawn( server, 'sudo stdbuf -o0 -e0 %(DIR)s/ixcp.py --control eff' % {'DIR': DIR}, 'sudo kill {pid}', cwd=DIR) proc.settimeout(1) ixcp = proc.makefile('rb') cmdline = ' --server=%s:%d %s --report-stats=1 %s --qps-warmup=%d' % ( bench_common.get_host_ip(server), IX_PORT, WORKLOADS[args.workload], PATTERNS[args.pattern], WARMUP) mutilate = bench_common.mutilate_benchmark(proc_manager, clients, cmdline, CONNECTIONS, THREADS, RECORDS, DEPTH, LATENCY_CONNECTIONS, LATENCY_QPS, TIME) ixcp = bench_common.generator_from_file(ixcp) mutilate_file = open(args.outdir + '/mutilate.out', 'w') ixcp_file = open(args.outdir + '/ixcp.out', 'w') for src, line in bench_common.multiplexer(mutilate, ixcp): if src == 0: if line is None: break print >> mutilate_file, line[:-1], print >> mutilate_file, server.run( shlex.split('sudo %(DIR)s/ixcp.py --print-power' % {'DIR': DIR})).output[:-1], if args.background: server.run( shlex.split('kill -USR1 %d' % (background_pid, ))) line = bench_common.readline_retry(sha1_bench)[:-1] parts = line.split() print >> mutilate_file, parts[3] else: print >> mutilate_file, '' elif src == 1: print >> ixcp_file, line[:-1]
def bench(args, server, clients, numa_node, power, freq, corelist, htlist, backlist): core_count = len(corelist) ht_count = len(htlist) corelist = sorted(corelist + htlist) mask = reduce(lambda x, y: x | 1 << int(y), corelist, 0) with bench_common.ProcessManager() as proc_manager: if args.target == 'linux': port = LINUX_PORT corelist_str = ','.join(map(str, corelist)) proc_manager.spawn( server, 'stdbuf -o0 -e0 numactl -m %(numa_node)d %(DIR)s/memcached -k -Mm 1024 -c 4096 -b 8192 -t %(count)d -T %(cores)s' % { 'DIR': DIR, 'numa_node': numa_node, 'count': len(corelist), 'cores': corelist_str }, 'kill {pid}') bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), port) elif args.target == 'ix': port = IX_PORT channel, pid = proc_manager.spawn( server, 'sudo stdbuf -o0 -e0 %(DIR)s/ix -c /etc/ix.conf -- %(DIR)s/memcached -k -Mm 1024 -c 4096 -o hashpower=20' % {'DIR': DIR}, 'sudo kill {pid}') bench_common.wait_for_network(clients[0], bench_common.get_host_ip(server), port) server.run( shlex.split('sudo sh -c "rm -f %(DIR)s/block-*.fifo"' % {'DIR': DIR})) corelist = ','.join(map(str, corelist)) server.run(shlex.split('sudo %(DIR)s/ixcp.py --cpulist %(cores)s' % { 'DIR': DIR, 'cores': corelist }), cwd=DIR) bench_common.consume(channel) cmdline = ' --server=%s:%d %s --report-stats=1 --qps-function=triangle:10000:15010000:600:0 --stop-latency 99:500' % ( bench_common.get_host_ip(server), port, WORKLOADS[args.workload]) mutilate = bench_common.mutilate_benchmark(proc_manager, clients, cmdline, CONNECTIONS, THREADS, RECORDS, DEPTH, LATENCY_CONNECTIONS, LATENCY_QPS, TIME) if args.background: proc, background_pid = proc_manager.spawn( server, 'stdbuf -o0 -e0 taskset -c %(cores)s %(DIR)s/sha1_bench -T %(count)d -s 41943040' % { 'DIR': DIR, 'cores': ','.join(map(str, backlist)), 'count': len(backlist) }, 'kill {pid}') proc.settimeout(1) sha1_bench = proc.makefile('rb') power.start() for line in mutilate: if line is None: break parts = line.split() if len(parts) < 2 or parts[1] != 'read': continue print '%d/%d %08x %d' % (core_count, ht_count, mask, freq), print line[:-1], if args.target == 'linux': print power.read(), elif args.target == 'ix': print server.run( shlex.split('sudo %(DIR)s/ixcp.py --print-power' % {'DIR': DIR})).output[:-1], if args.background: server.run(shlex.split('kill -USR1 %d' % (background_pid, ))) line = bench_common.readline_retry(sha1_bench)[:-1] parts = line.split() print parts[3] else: print ''