def main(): gc.disable() #benchmarks = dict(matrix = "/home/sources/kvmtests/benches/matrix.py -s 512 -r 1") #events = "cycles,instructions,task-clock" events = get_useful_events() out = open("results/raw_results_single", "a") perf_single(benchmarks, out=out, evs=events) out = open("results/raw_results_double", "a") perf_double(benchmarks, out=out, evs=events)
def main(): parser = argparse.ArgumentParser(description="Run experiments") parser.add_argument("--debug", default=False, const=True, action="store_const", help="enable debug mode") parser.add_argument("-t", "--tests", default=["single", "double", "random", "perf_single"], nargs="*") parser.add_argument("-e", "--events", default=perftool.get_useful_events(), nargs="*") parser.add_argument("--db", required=True, help="name of mongo database") parser.add_argument( "--no-start", type=bool, default=False, help="Assume that instances are already started. Images are not regenerated, \ VMs are not killed on start.", ) parser.add_argument("--idlness", type=bool, const=True, default=False, nargs="?", help="measure idlness and exit") args = parser.parse_args() # INIT if os.geteuid() != 0: sys.exit("you need root to run this scrips") setrlimit(RLIMIT_NOFILE, (10240, 10240)) # signal(SIGCHLD, SIG_IGN) # signal(SIGINT, SIG_IGN) topology = numa.OnlineCPUTopology() log.notice("topology:\n%s" % topology) cpu_name = numa.get_cpu_name() log.debug("cpu name: %s" % cpu_name) # events = perftool.get_useful_events() # log.debug("useful events: %s", events) mongo_client = MongoClient() db = mongo_client[args.db] gc.disable() # MACHINE-SPECIFIC CONFIGURATION hostname = socket.gethostname() if hostname == "fx": run("hdparm -S 0 /dev/sda", sudo="root") cpus_near = [] cpu1 = topology.cpus[0] cpu2 = topology.ht_siblings[cpu1] cpus_near = [cpu1, cpu2] del cpu1, cpu2 cpus_far = topology.cpus_no_ht[:2] cpus_all = topology.cpus # cfg.idfactor = 10 elif hostname == "ux32vd": cpus_near = topology.cpus_no_ht cpus_far = topology.cpus_no_ht cpus_all = topology.cpus_no_ht cfg.idfactor = 3 elif hostname == "p1": cpus_near = topology.cpus_no_ht cpus_far = None cpus_all = cpus_near else: raise Exception("No profile for machine % " % hostname) print("cpus_near:", cpus_near, "cpus_far:", cpus_far) if args.debug: log.critical("Warning! Debug enabled. Using debug database") log.notice(args) cfg.warmup = 0.5 cfg.measure = 0.5 cfg.idfactor *= 10 db = mongo_client[args.db + "_debug"] # PRE-FLIGHT CHECK if not args.no_start: warning("killing all kvms") cgmgr.graceful(timeout=30) subprocess.call("/home/sources/perftests/regen_img.sh") subprocess.check_output("sync") if args.idlness: log.debug("measuring idlness") return print("idleness is", check_idleness()) # EXPERIMENT 1: SINGLE TASK PERFORMANCE (IDEAL PERFORMANCE) if "single" in args.tests: instances = start_instances([cpus_near[0]]) inst = instances[0] measure_single(cg=inst.cg, Popen=inst.Popen) stop_instances(instances) # EXPERIMENT 2: TWO TASK PERFORMANCE # near if "double" in args.tests: instances = start_instances(cpus_near) inst1 = instances[0] inst2 = instances[1] measure_double(cg1=inst1.cg, cg2=inst2.cg, Popen1=inst1.Popen, Popen2=inst2.Popen) stop_instances(instances) # far if cpus_far: instances = start_instances(cpus_far) inst1 = instances[0] inst2 = instances[1] measure_double(cg1=inst1.cg, cg2=inst2.cg, Popen1=inst1.Popen, Popen2=inst2.Popen) stop_instances(instances) # EXPERIMENT 3: arbitrary tests if "random" in args.tests: with VMS(cpus_all) as instances: arbitrary_tests(instances=instances, cpucfg=[1 for _ in cpus_all], num=1000) # EXPERIMENT 4: test with all counters enabled if "perf_single" in args.tests: db.single.drop() col = db.single with RPCMgr("0") as vms: vm = vms["0"] wait_idleness(cfg.idfactor * 2) r = perf_single(vm=vm, cfg=cfg, col=col, events=args.events) # EXPERIMENT 5: measurements stability if "perf_stab" in args.tests: vmname = str(cpus_far[0]) with RPCMgr(vmname) as vms: vm = vms[vmname] log.notice("running tests on VM " + vmname) wait_idleness(cfg.idfactor * 2) for attempt in range(3): for name, evset in evsets.items(): for t in [1, 3, 10, 30, 90, 180, 300]: # for t in [30]: cfg.measure = t if not args.debug else 1 col = db["stab_%s_%ss" % (name, t)] r = perf_single(vm=vm, cfg=cfg, col=col, benchmarks=benchmarks, events=evset) # EXPERIMENT 6: measurements stability if "myperf_stab" in args.tests: vmname = str(cpus_far[0]) with RPCMgr(vmname) as vms: vm = vms[vmname] log.notice("running tests on VM " + vmname) wait_idleness(cfg.idfactor * 2) for attempt in range(3): for t in [1, 3, 10, 30, 90, 180, 300]: # for t in [90]: log.error("gc-collected %s elemets" % gc.collect()) cfg.measure = t if not args.debug else 1 col = db["stab_%ss" % t] r = myperf_single(vm=vm, cfg=cfg, col=col, benchmarks=benchmarks) input("press any key to continue")
import time import sys import pdb import os import gc info = lambda *x: cprint(" ".join(map(str, x)), color="green") warning = lambda *x: cprint(" ".join(map(str, x)), color="yellow") error = lambda *x: cprint(" ".join(map(str, x)), color="red") die = lambda m: sys.exit(m) log = Log("MASTER") evsets = dict( basic="cycles instructions".split(), partial="cycles instructions cache-references cache-misses branches branch-misses page-faults minor-faults major-faults LLC-loads LLC-load-misses LLC-stores".split(), full=perftool.get_useful_events(), ) class cfg: warmup = 30 measure = 180 idfactor = 7 vmstart = 5 # how much time a VM usually starts benchmarks = dict( matrix="/home/sources/kvmtests/benches/matrix 2048", integer="/home/sources/kvmtests/benches/int", pgbench="sudo -u postgres pgbench -c 20 -s 10 -T 100000", nginx_static="siege -c 100 -t 666h http://localhost/big_static_file", # TODO: too CPU consuming,