Merge branch 'foo' of github.com:ctiller/grpc into foo

pull/10439/head
Craig Tiller 8 years ago
commit 763667ce29
  1. 40
      tools/profiling/microbenchmarks/bm_diff.py
  2. 1
      tools/profiling/microbenchmarks/bm_json.py
  3. 2
      tools/profiling/microbenchmarks/speedup.py

@ -45,6 +45,16 @@ import jobset
import itertools
import speedup
_INTERESTING = (
'cpu_time',
'real_time',
'locks_per_iteration',
'allocs_per_iteration',
'writes_per_iteration',
'atm_cas_per_iteration',
'atm_add_per_iteration',
)
def changed_ratio(n, o):
if float(o) <= .0001: o = 0
if float(n) <= .0001: n = 0
@ -63,26 +73,6 @@ def median(ary):
def min_change(pct):
return lambda n, o: abs(changed_ratio(n,o)) > pct/100.0
nanos = {
'abs_diff': 5,
'pct_diff': 10,
}
counter = {
'abs_diff': 0.5,
'pct_diff': 10,
}
_INTERESTING = {
'cpu_time': nanos,
'real_time': nanos,
'locks_per_iteration': counter,
'allocs_per_iteration': counter,
'writes_per_iteration': counter,
'atm_cas_per_iteration': counter,
'atm_add_per_iteration': counter,
}
_AVAILABLE_BENCHMARK_TESTS = ['bm_fullstack_unary_ping_pong',
'bm_fullstack_streaming_ping_pong',
'bm_fullstack_streaming_pump',
@ -98,9 +88,9 @@ _AVAILABLE_BENCHMARK_TESTS = ['bm_fullstack_unary_ping_pong',
argp = argparse.ArgumentParser(description='Perform diff on microbenchmarks')
argp.add_argument('-t', '--track',
choices=sorted(_INTERESTING.keys()),
choices=sorted(_INTERESTING),
nargs='+',
default=sorted(_INTERESTING.keys()),
default=sorted(_INTERESTING),
help='Which metrics to track')
argp.add_argument('-b', '--benchmarks', nargs='+', choices=_AVAILABLE_BENCHMARK_TESTS, default=['bm_cq'])
argp.add_argument('-d', '--diff_base', type=str)
@ -181,9 +171,11 @@ class Benchmark:
new = self.samples[True][f]
old = self.samples[False][f]
if not new or not old: continue
mdn_diff = abs(median(new) - median(old))
print '%s: new=%r old=%r mdn_diff=%r' % (f, new, old, mdn_diff)
s = speedup.speedup(new, old)
if s:
self.final[f] = '%d%%' % s
if s and mdn_diff > 0.5:
self.final[f] = '%+d%%' % s
return self.final.keys()
def skip(self):

@ -203,4 +203,5 @@ def expand_json(js, js2 = None):
row['real_time'] = bm2['real_time']
row['iterations'] = bm2['iterations']
bm2['already_used'] = True
break
yield row

@ -30,7 +30,7 @@
from scipy import stats
import math
_THRESHOLD = 0.01
_THRESHOLD = 0.001
def scale(a, mul):
return [x*mul for x in a]

Loading…
Cancel
Save