47
47
import mx
48
48
49
49
50
+ def print_line (l ):
51
+ print ('=' * l )
52
+
53
+
50
54
def get_suite (name ):
51
55
suite_name = name .lstrip ('/' )
52
56
suite = mx .suite (suite_name , fatalIfMissing = False )
@@ -186,13 +190,17 @@ def _bisect_benchmark(argv, bisect_id, email_to):
186
190
args .benchmark_criterion = sec .get ('benchmark_criterion' , 'BEST' )
187
191
args .enterprise = sec .getboolean ('enterprise' , False )
188
192
args .no_clean = sec .getboolean ('no_clean' , False )
193
+ args .rerun_with_commands = sec ['rerun_with_commands' ]
189
194
else :
190
195
parser = argparse .ArgumentParser ()
191
196
parser .add_argument ('bad' , help = "Bad commit for bisection" )
192
197
parser .add_argument ('good' , help = "Good commit for bisection" )
193
198
parser .add_argument ('build_command' , help = "Command to run in order to build the configuration" )
194
199
parser .add_argument ('benchmark_command' ,
195
200
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 ';')" )
196
204
parser .add_argument ('--benchmark-criterion' , default = 'BEST' ,
197
205
help = "Which result parameter should be used for comparisons" )
198
206
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):
203
211
204
212
fetched_enterprise = [False ]
205
213
206
- def benchmark_callback (suite , commit ):
214
+ def checkout_suite (suite , commit ):
207
215
suite .vc .update_to_branch (suite .vc_dir , commit )
208
216
mx .run_mx (['sforceimports' ], suite = suite )
209
217
mx .run_mx (['--env' , 'ce' , 'sforceimports' ], suite = get_suite ('/vm' ))
@@ -223,6 +231,9 @@ def benchmark_callback(suite, commit):
223
231
if args .enterprise :
224
232
debug_str += " graal-enterprise={}" .format (get_commit (get_suite ('/vm-enterprise' )))
225
233
print (debug_str )
234
+
235
+ def checkout_and_build_suite (suite , commit ):
236
+ checkout_suite (suite , commit )
226
237
build_command = shlex .split (args .build_command )
227
238
if not args .no_clean :
228
239
try :
@@ -235,8 +246,11 @@ def benchmark_callback(suite, commit):
235
246
retcode = mx .run (build_command , nonZeroIsFatal = False )
236
247
if retcode :
237
248
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 )
238
252
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 )
240
254
if retcode :
241
255
if args .benchmark_criterion == 'WORKS' :
242
256
return sys .maxsize
@@ -260,6 +274,28 @@ def benchmark_callback(suite, commit):
260
274
print ()
261
275
print (summary )
262
276
277
+ if args .rerun_with_commands :
278
+ print ('\n \n Rerunning 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
+
263
299
send_email (
264
300
bisect_id ,
265
301
email_to ,
0 commit comments