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
def distribution_with_subsampling(data, skip=22, mode='hist'): standard = data.standard withskip = data.withskip plots, labels = [], [] tuples = [] for test, st_ipcs, raw_skp in dictzip(standard, withskip): skp_ipc = [] for skp in raw_skp: instr = mean(skp['instructions'][skip:]) cycles = mean(skp['cycles'][skip:]) if not cycles: continue skp_ipc.append(instr/cycles) tuples.append((test, st_ipcs, skp_ipc)) tuples = sorted(tuples, key=lambda x: x[0]) for test, isolated, shared in tuples: # if prec >0.1: continue plots.append(isolated) plots.append(shared) labels.append(test) myboxplot(plots, labels=labels, legend=["frozen env meas. 50ms", "frozen with skip %sms" % (skip*2)])
def compare(data1, data2, legend): assert data1, "data1 cannot be empty" assert data2, "data2 cannot be empty" def ipc(data): return [t[0]/t[1] for t in data] data, labels = [], [] for test, p, s in sorted(dictzip(data1,data2)): print(test, p[:2], s[:2]) labels.append(test) data.append(p) data.append(ipc(s)) myboxplot(data, labels=labels, legend=legend, notch=True)
def distribution(data, mode='hist'): data = pickle.load(open(data, 'rb')) pure = data.result.pure # data from pure performance isolation quasi = data.result.quasi # data from quasi isolation if mode == 'hist': for i, (test, ref, measurements) in enumerate(dictzip(pure, quasi)): # print(test, len(ref), len(measurements)) print(ref) p.subplot(4,2,i+1) p.title(test) p.hist(ref, bins=50, label="real isolation", alpha=0.7) p.hist(measurements, bins=50, label="quasi-isolation", alpha=0.7) p.legend(loc="best") p.xlim(0,3) elif mode == 'boxplot': labels = [] data = [] for i, (test, ref, measurements) in enumerate(sorted(dictzip(pure, quasi))): labels.append(test) data.append(ref) data.append(measurements) box = myboxplot(data, labels=labels, notch=True)
def analyze_reverse2(data): data = pickle.load(open(data, 'rb')).result isolated = data.isolated shared = data.shared plots, labels = [], [] tuples = [] for test, isolated, shared in dictzip(isolated, shared): prec = precision2(shared, isolated) tuples.append((test, isolated, shared, prec)) tuples = sorted(tuples, key=lambda x: x[3]) for test, isolated, shared, prec in tuples: # if prec >0.1: continue plots.append(isolated) plots.append(shared) labels.append("{} {:.1%}".format(test, prec)) myboxplot(plots, labels=labels)
def loosers(num:int=10, interval:int=100, pause:float=0.0, vms=None): """ Detect starving applications. """ shared_perf = defaultdict(list) frozen_perf = defaultdict(list) while num>0: print(num, "measurements left") shared_sampling(num=10, interval=interval, pause=pause, result=shared_perf, vms=vms) freezing_sampling(num=10, interval=interval, pause=pause, result=frozen_perf, vms=vms) num -= 10 result = {} for bench, sh_perf, fr_perf in dictzip(shared_perf, frozen_perf): ratio = mean(sh_perf) / mean(fr_perf) result[bench] = ratio print("our technique:") print(sorted(result.items(), key=lambda v: v[1])) return result
def real_loosers3(num:int=10, interval:int=10*1000, pause:float=0.1, vms=None): """ Detect starving applications. Improved version """ shared_perf = defaultdict(list) frozen_perf = defaultdict(list) prints("real_loosers3 iterations ", end="") for i,x in enumerate(range(num)): prints("{i}/{num}", end=" "); sys.stdout.flush() shared_thr_sampling(num=1, interval=interval, result=shared_perf, vms=vms) freezing_sampling(num=1, interval=interval, pause=0.1, result=frozen_perf, vms=vms) sleep(pause) result = {} for vm, sh_perf, fr_perf in dictzip(shared_perf, frozen_perf): ratio = mean(sh_perf) / mean(fr_perf) result[vm] = ratio result = sorted(result.items(), key=lambda v: v[1]) print("Loosers: straight forward technique:\n", result) return result, shared_perf, frozen_perf