16 """ Runs the entire bm_*.py pipeline, and possible comments on the PR """
19 import multiprocessing
26 os.path.join(os.path.dirname(sys.argv[0]),
'..',
'..',
'run_tests',
30 os.path.join(os.path.dirname(sys.argv[0]),
'..',
'..',
'..',
'run_tests',
42 argp = argparse.ArgumentParser(
43 description=
'Perform diff on microbenchmarks')
44 argp.add_argument(
'-t',
46 choices=sorted(bm_constants._INTERESTING),
48 default=sorted(bm_constants._INTERESTING),
49 help=
'Which metrics to track')
50 argp.add_argument(
'-b',
53 choices=bm_constants._AVAILABLE_BENCHMARK_TESTS,
54 default=bm_constants._AVAILABLE_BENCHMARK_TESTS,
55 help=
'Which benchmarks to run')
56 argp.add_argument(
'-d',
59 help=
'Commit or branch to compare the current one to')
65 help=
'Name of baseline run to compare to. Usually just called "old"')
66 argp.add_argument(
'-r',
70 help=
'Regex to filter benchmarks run')
77 'Number of times to loops the benchmarks. More loops cuts down on noise'
79 argp.add_argument(
'-j',
82 default=multiprocessing.cpu_count(),
83 help=
'Number of CPUs to use')
84 argp.add_argument(
'--pr_comment_name',
86 default=
"microbenchmarks",
87 help=
'Name that Jenkins will use to comment on the PR')
88 argp.add_argument(
'--counters', dest=
'counters', action=
'store_true')
89 argp.add_argument(
'--no-counters', dest=
'counters', action=
'store_false')
90 argp.set_defaults(counters=
True)
91 args = argp.parse_args()
92 assert args.diff_base
or args.old,
"One of diff_base or old must be set!"
94 print(
"WARNING: This run will likely be noisy. Increase loops.")
99 """Run fn until it doesn't stop because of EINTR"""
106 if e.errno != errno.EINTR:
119 where_am_i = subprocess.check_output(
120 [
'git',
'rev-parse',
'--abbrev-ref',
'HEAD']).strip()
121 subprocess.check_call([
'git',
'checkout', args.diff_base])
125 subprocess.check_call([
'git',
'checkout', where_am_i])
126 subprocess.check_call([
'git',
'submodule',
'update'])
130 args.regex, args.counters)
132 args.regex, args.counters)
135 random.shuffle(jobs_list, random.SystemRandom().random)
136 jobset.run(jobs_list, maxjobs=args.jobs)
138 diff, note, significance =
bm_diff.diff(args.benchmarks, args.loops,
139 args.regex, args.track, old,
'new',
142 text =
'[%s] Performance differences noted:\n%s' % (
143 args.pr_comment_name, diff)
145 text =
'[%s] No significant performance differences' % args.pr_comment_name
147 text = note +
'\n\n' + text
149 check_on_pr.check_on_pr(
'Benchmark',
'```\n%s\n```' % text)
152 if __name__ ==
'__main__':