Skip to content

Commit b3b25fc

Browse files
committed
[GR-38753] Benchmark bisect 'rerun with commands' feature.
PullRequest: graalpython/2266
2 parents f086f80 + 5c3d7ae commit b3b25fc

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

bisect-benchmark.ini

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ build_command = mx --dy /compiler build
2727
# "-XX ..." list is not part of the command, that's already part of the output
2828
benchmark_command = mx --dy /compiler benchmark micro:try-except-simple
2929

30+
# Once the good and bad commits are identified, the tool will run all the
31+
# following benchmark commands on both the good and bad revisions. One can
32+
# run the benchmarks again with some extra logging, IGV dumping, ...
33+
#
34+
# Individual commands can be separated by ';'. Trailing whitespace including
35+
# newlines is removed from the commands.
36+
#
37+
# The example commands below are good default that should provide good insight
38+
# into the regression at hand:
39+
# * "--checkup" runs the benchmark with extra iterations, and extra compilation
40+
# and GC logging
41+
# * "--cpusampler" with delay of 10000ms (adjust if the whole benchmark command
42+
# runs for less than that)
43+
# * "--cputracer" and IGV dumping: they filter the roots with name "*measure*",
44+
# adjust that to the benchmark main function(s)
45+
rerun_with_commands =
46+
mx --dy /compiler benchmark micro:try-except-simple -- --checkup ;
47+
mx --dy /compiler benchmark micro:try-except-simple -- --cpusampler --cpusampler.Delay=10000 ;
48+
mx --dy /compiler benchmark micro:try-except-simple -- --cputracer --cputracer.TraceStatements --cputracer.FilterRootName=measure ;
49+
mx --dy /compiler benchmark micro:try-except-simple -- --vm.Dgraal.Dump=Truffle:2 --vm.Dgraal.MethodFilter="*measure*"
50+
3051
# The first known "bad" merge commit for bisection. Try to use long commit
3152
# SHAs, the CI cache has higher probability of short SHAs being ambiguous
3253
bad = 1234deadbeef

mx.graalpython/mx_graalpython_bisect.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
import mx
4848

4949

50+
def print_line(l):
51+
print('=' * l)
52+
53+
5054
def get_suite(name):
5155
suite_name = name.lstrip('/')
5256
suite = mx.suite(suite_name, fatalIfMissing=False)
@@ -186,13 +190,17 @@ def _bisect_benchmark(argv, bisect_id, email_to):
186190
args.benchmark_criterion = sec.get('benchmark_criterion', 'BEST')
187191
args.enterprise = sec.getboolean('enterprise', False)
188192
args.no_clean = sec.getboolean('no_clean', False)
193+
args.rerun_with_commands = sec['rerun_with_commands']
189194
else:
190195
parser = argparse.ArgumentParser()
191196
parser.add_argument('bad', help="Bad commit for bisection")
192197
parser.add_argument('good', help="Good commit for bisection")
193198
parser.add_argument('build_command', help="Command to run in order to build the configuration")
194199
parser.add_argument('benchmark_command',
195200
help="Command to run in order to run the benchmark. Output needs to be in mx's format")
201+
parser.add_argument('--rerun-with-commands',
202+
help="Re-run the bad and good commits with this benchmark command(s) "
203+
"(multiple commands separated by ';')")
196204
parser.add_argument('--benchmark-criterion', default='BEST',
197205
help="Which result parameter should be used for comparisons")
198206
parser.add_argument('--enterprise', action='store_true', help="Whether to checkout graal-enterprise")
@@ -203,7 +211,7 @@ def _bisect_benchmark(argv, bisect_id, email_to):
203211

204212
fetched_enterprise = [False]
205213

206-
def benchmark_callback(suite, commit):
214+
def checkout_suite(suite, commit):
207215
suite.vc.update_to_branch(suite.vc_dir, commit)
208216
mx.run_mx(['sforceimports'], suite=suite)
209217
mx.run_mx(['--env', 'ce', 'sforceimports'], suite=get_suite('/vm'))
@@ -223,6 +231,9 @@ def benchmark_callback(suite, commit):
223231
if args.enterprise:
224232
debug_str += " graal-enterprise={}".format(get_commit(get_suite('/vm-enterprise')))
225233
print(debug_str)
234+
235+
def checkout_and_build_suite(suite, commit):
236+
checkout_suite(suite, commit)
226237
build_command = shlex.split(args.build_command)
227238
if not args.no_clean:
228239
try:
@@ -235,8 +246,11 @@ def benchmark_callback(suite, commit):
235246
retcode = mx.run(build_command, nonZeroIsFatal=False)
236247
if retcode:
237248
raise RuntimeError("Failed to execute the build command for {}".format(commit))
249+
250+
def benchmark_callback(suite, commit, bench_command=args.benchmark_command):
251+
checkout_and_build_suite(suite, commit)
238252
output = mx.OutputCapture()
239-
retcode = mx.run(shlex.split(args.benchmark_command), out=mx.TeeOutputCapture(output), nonZeroIsFatal=False)
253+
retcode = mx.run(shlex.split(bench_command), out=mx.TeeOutputCapture(output), nonZeroIsFatal=False)
240254
if retcode:
241255
if args.benchmark_criterion == 'WORKS':
242256
return sys.maxsize
@@ -260,6 +274,28 @@ def benchmark_callback(suite, commit):
260274
print()
261275
print(summary)
262276

277+
if args.rerun_with_commands:
278+
print('\n\nRerunning the good and bad commits with extra benchmark commands:')
279+
current_result = result
280+
current_suite = primary_suite
281+
while current_result.subresults and current_result.bad_index in current_result.subresults:
282+
downstream_suite = get_downstream_suite(current_suite)
283+
next_result = current_result.subresults[current_result.bad_index]
284+
if not next_result.good_commit or not next_result.bad_commit:
285+
print("Next downstream suite {} does not have both good and bad commits".format(downstream_suite.name))
286+
break
287+
print("Recursing to downstream suite: {}, commit: {}".format(downstream_suite.name, current_result.bad_commit))
288+
checkout_suite(current_suite, current_result.bad_commit)
289+
current_result = next_result
290+
current_suite = downstream_suite
291+
for commit in [current_result.good_commit, current_result.bad_commit]:
292+
print_line(80)
293+
print("Commit: {}".format(commit))
294+
checkout_and_build_suite(current_suite, commit)
295+
for cmd in args.rerun_with_commands.split(";"):
296+
print_line(40)
297+
mx.run(shlex.split(cmd.strip()), nonZeroIsFatal=False)
298+
263299
send_email(
264300
bisect_id,
265301
email_to,

0 commit comments

Comments
 (0)