Beispiel #1
0
def reverse_shared(num:int=1, time:float=0.1, pause:float=0.1, vms=None):
  assert vms, "vms is a mandatory argument"
  result = defaultdict(list)

  def measure(vm, r):
    ins, cycles = vm.stat(time)
    r[vm.bname] = ins / cycles

  for i in range(num):
    print("measure %s out of %s" % (i+1, num))
    for victim in vms:
      """victim is a VM that we are going to freeze"""
      shared, exklusiv = {}, {}
      # shared phase
      threadulator(measure, [(vm, shared) for vm in vms if vm != victim])
      # "stop victim" phase
      victim.freeze()
      threadulator(measure, [(vm, exklusiv) for vm in vms if vm != victim])
      victim.unfreeze()
      # calculate results
      try:
        for bench, pShared, pExcl in dictzip(shared, exklusiv):
          key = victim.bname, bench
          value = pShared / pExcl
          result[key].append(value)
      except KeyError:
        print("something was wrong, we lost a datapoint")
      sleep(pause)
  return result
Beispiel #2
0
def performance(vms, interval=30*1000):
  results = {}
  def measure(vm):
    ipc = vm.ipcstat(interval=interval)
    results[vm] = ipc
  threadulator(measure, [[vm] for vm in vms])
  print(sorted(results.items(), key=lambda kv: kv[0].name), geomean(results.values()))
  return geomean(results.values())
Beispiel #3
0
def interference(interval:int=180*1000, warmup:int=15, mode=None, vms=None):
  assert mode in ['sibling', 'distant']
  if mode == 'sibling':
    cpu1 = topology.no_ht[0]
    cpu2 = topology.ht_map[cpu1][0]
  else:
    cpu1, cpu2 = topology.no_ht[:2]

  print("stopping all but 2 vms because we need only two")
  for vm in vms[2:]:
    vm.stop()
  vm1, vm2 = vms[:2]
  vm1.start()
  vm2.start()

  sleep(13)
  vm1.set_cpus([cpu1])
  vm2.set_cpus([cpu2])

  benchmarks = list(sorted(basis))
  result = defaultdict(lambda: [None, None])
  for bmark1, bmark2 in product(benchmarks, repeat=2):
    if (bmark2, bmark1) in result:
      continue
    key = (bmark1, bmark2)
    print(key)

    wait_idleness(IDLENESS*6)
    p1 = vm1.Popen(basis[bmark1])
    sleep(1)  # reduce oscillation when two same applications are launched
    p2 = vm2.Popen(basis[bmark2])
    sleep(warmup)

    def get_ipc(idx, vm):
      ipc = vm.ipcstat(interval)
      result[key][idx] = ipc
    threadulator(get_ipc, [(0, vm1), (1, vm2)])

    print(result)
    for vm in [vm1, vm2]:
      ret = vm.pipe.poll()
      if ret is not None:
        print("Test {bmark} on {vm} died with {ret}! Manual intervention needed\n\n" \
              .format(bmark=vm.bname, vm=vm, ret=ret))
        import pdb; pdb.set_trace()

    p1.killall()
    p2.killall()
Beispiel #4
0
def ragged(time:int=10, interval:int=1, vms=None):
  from functools import partial
  from qemu import ipcistat
  f = partial(ipcistat, events=['cycles','instructions', 'cache-misses', 'minor-faults'], time=10.0, interval=1)
  args = [(vm,) for vm in vms]
  threadulator(f, args)