コード例 #1
0
ファイル: perforator.py プロジェクト: kopchik/perforator
def all_events(interval:int=180*1000, warmup:int=15, vms=None):
  from perf import perftool
  events = perftool.get_events()
  print("monitoring events:", events)
  for vm in vms[1:]:
    vm.stop()
  vm = vms[0]
  vm.start()
  sleep(BOOT_TIME)
  cpu = topology.no_ht[0]
  vm.set_cpus([cpu])

  result = {}
  for bmark, cmd in basis.items():
    wait_idleness(IDLENESS*4)
    print("measuring", bmark)
    vm.Popen(cmd)
    sleep(warmup)

    ipc = vm.stat(interval=interval, events=events)
    result[bmark] = ipc

    ret = vm.pipe.poll()
    if ret is not None:
      print("Test {bmark} on {vm} died with {ret}! Manual intervention needed\n\n" \
            .format(bmark=bmark, vm=vm, ret=ret))
      import pdb; pdb.set_trace()
    vm.pipe.killall()

  print(result)
  return result
コード例 #2
0
ファイル: perforator.py プロジェクト: kopchik/perforator
def power_consumption(n=4, num=10, vms=None):
  """ Dead-simple optimization of partial loads. """
  cpus_ranked = cpu_enum()
  def report(header, t=30):
    performance, ipc = sysperf(t=t)
    print("{header}: {perf:.2f}B insns, ipc: {ipc:.4f}"
          .format(header=header, perf=performance, ipc=ipc))
    return performance, ipc

  report("before start", t=3)

  # SPAWN
  active_vms = []
  active_cpus = []
  benchmarks = list(basis.items())
  for i, vm, cpu in zip(range(n), vms, cpus_ranked):
    bmark, cmd = choice(benchmarks)
    print(cpu, bmark, vm)
    vm.pipe = vm.Popen(cmd, stdout=DEVNULL, stderr=DEVNULL)
    vm.bname = bmark
    vm.set_cpus([cpu])
    active_cpus.append(cpu)
    active_vms.append(vm)

  input("press enter when done")

  stats, _, _ = real_loosers3(interval=1*1000, num=num, vms=active_vms)
  p1, ipc1 = report("after finding loosers")
  print(stats)
  for i, (vm, degr) in zip(range(2), stats):
    print(vm, vm.bname)
    for cpu in topology.no_ht:
      if cpu not in active_cpus:
        for oldcpu in vm.cpus:
          active_cpus.remove(oldcpu)
        vm.set_cpus([cpu])
        active_cpus.append(cpu)
  print("RELOCATION DONE")

  stats, _, _ = real_loosers3(interval=1*1000, num=num, vms=active_vms)
  p2, ipc2 = report("after fixing loosers")
  print("SPEEDUP", p2/p1)
  input("press enter when done")
コード例 #3
0
ファイル: test_single.py プロジェクト: kopchik/perftest
def single(vm, prefix):
  outdir = s("${prefix}/single/")
  if not exists(outdir):
    makedirs(outdir)

  remains = len(basis)
  for name, cmd in basis.items():
    log.debug("remains %s tests" % remains)
    remains -= 1
    outfile = s("${prefix}/single/${name}")

    log.debug("waiting for idleness")
    wait_idleness(IDLENESS*2.3)
    log.debug("starting %s" % name)
    p = vm.Popen(cmd)
    log.debug("warming up for %s" % WARMUP_TIME)
    time.sleep(WARMUP_TIME)
    log.debug("starting measurements")
    vm.stat(outfile)
    assert p.poll() is None, "test unexpectedly terminated"
    log.debug("finishing test")
    p.killall()
    gc.collect()
コード例 #4
0
ファイル: perf_plot.py プロジェクト: kopchik/perftest
  parser.add_argument('-b', '--benches', nargs='+', default=[], help="Select benches to measure")
  args = parser.parse_args()


  try:
    os.kill(args.pid, 0)
  except ProcessLookupError:
    raise Exception("no such pid: %s" % args.pid)

  rpc = rpyc.connect(args.addr, port=6666)
  RPopen = rpc.root.Popen

  start, stop, step = args.interval
  interval = range(start, stop+1, step)

  for name,cmd in basis.items():
    if name not in args.benches:
      continue
    wait_idleness(IDLENESS)
    print("launching %s"%name)
    if name != "pgbench":
      cmd = "bencher.py -s 100000 -- "+cmd
    p = RPopen(cmd)
    sleep(WARMUP_TIME)

    for i in interval:
      print("%s (%s)" % (i, interval))
      outdir = "%s/%s/" % (args.outdir, i)
      os.path.exists(outdir) or os.makedirs(outdir)
      perfcmd = PERFCMD.format(interval=i, events="instructions:G",
                             output=outdir+name, time=args.time, pid=args.pid)
コード例 #5
0
ファイル: placer.py プロジェクト: kopchik/perftools
def generate_load(num=8, cpus=topology.all):
  load = []
  for cpu in range(num):
    bmark, cmd = random.choice(list(basis.items()))
    load.append((bmark, cpu))
  return load