47
47
import mx
48
48
49
49
50
+ def hr (l ):
51
+ print ('=' * l )
52
+
50
53
def get_suite (name ):
51
54
suite_name = name .lstrip ('/' )
52
55
suite = mx .suite (suite_name , fatalIfMissing = False )
@@ -186,13 +189,17 @@ def _bisect_benchmark(argv, bisect_id, email_to):
186
189
args .benchmark_criterion = sec .get ('benchmark_criterion' , 'BEST' )
187
190
args .enterprise = sec .getboolean ('enterprise' , False )
188
191
args .no_clean = sec .getboolean ('no_clean' , False )
192
+ args .rerun_with_commands = sec ['rerun_with_commands' ]
189
193
else :
190
194
parser = argparse .ArgumentParser ()
191
195
parser .add_argument ('bad' , help = "Bad commit for bisection" )
192
196
parser .add_argument ('good' , help = "Good commit for bisection" )
193
197
parser .add_argument ('build_command' , help = "Command to run in order to build the configuration" )
194
198
parser .add_argument ('benchmark_command' ,
195
199
help = "Command to run in order to run the benchmark. Output needs to be in mx's format" )
200
+ parser .add_argument ('--rerun-with-commands' ,
201
+ help = "Re-run the bad and good commits with this benchmark command(s) "
202
+ "(multiple commands separated by '|')" )
196
203
parser .add_argument ('--benchmark-criterion' , default = 'BEST' ,
197
204
help = "Which result parameter should be used for comparisons" )
198
205
parser .add_argument ('--enterprise' , action = 'store_true' , help = "Whether to checkout graal-enterprise" )
@@ -203,7 +210,7 @@ def _bisect_benchmark(argv, bisect_id, email_to):
203
210
204
211
fetched_enterprise = [False ]
205
212
206
- def benchmark_callback (suite , commit ):
213
+ def checkout_suite (suite , commit ):
207
214
suite .vc .update_to_branch (suite .vc_dir , commit )
208
215
mx .run_mx (['sforceimports' ], suite = suite )
209
216
mx .run_mx (['--env' , 'ce' , 'sforceimports' ], suite = get_suite ('/vm' ))
@@ -223,6 +230,9 @@ def benchmark_callback(suite, commit):
223
230
if args .enterprise :
224
231
debug_str += " graal-enterprise={}" .format (get_commit (get_suite ('/vm-enterprise' )))
225
232
print (debug_str )
233
+
234
+ def checkout_and_build_suite (suite , commit ):
235
+ checkout_suite (suite , commit )
226
236
build_command = shlex .split (args .build_command )
227
237
if not args .no_clean :
228
238
try :
@@ -235,8 +245,11 @@ def benchmark_callback(suite, commit):
235
245
retcode = mx .run (build_command , nonZeroIsFatal = False )
236
246
if retcode :
237
247
raise RuntimeError ("Failed to execute the build command for {}" .format (commit ))
248
+
249
+ def benchmark_callback (suite , commit , bench_command = args .benchmark_command ):
250
+ checkout_and_build_suite (suite , commit )
238
251
output = mx .OutputCapture ()
239
- retcode = mx .run (shlex .split (args . benchmark_command ), out = mx .TeeOutputCapture (output ), nonZeroIsFatal = False )
252
+ retcode = mx .run (shlex .split (bench_command ), out = mx .TeeOutputCapture (output ), nonZeroIsFatal = False )
240
253
if retcode :
241
254
raise RuntimeError ("Failed to execute benchmark for {}" .format (commit ))
242
255
match = re .search (r'{}.*duration: ([\d.]+)' .format (re .escape (args .benchmark_criterion )), output .data )
@@ -255,6 +268,28 @@ def benchmark_callback(suite, commit):
255
268
print ()
256
269
print (summary )
257
270
271
+ if args .rerun_with_commands :
272
+ print ('\n \n Rerunning the good and bad commits with extra benchmark commands:' )
273
+ current_result = result
274
+ current_suite = primary_suite
275
+ while current_result .subresults and current_result .bad_index in current_result .subresults :
276
+ downstream_suite = get_downstream_suite (current_suite )
277
+ next_result = current_result .subresults [current_result .bad_index ]
278
+ if not next_result .good_commit or not next_result .bad_commit :
279
+ print ("Next downstream suite {} does not have both good and bad commits" .format (downstream_suite .name ))
280
+ break
281
+ print ("Recursing to downstream suite: {}, commit: {}" .format (downstream_suite .name , current_result .bad_commit ))
282
+ checkout_suite (current_suite , current_result .bad_commit )
283
+ current_result = next_result
284
+ current_suite = downstream_suite
285
+ for commit in [current_result .good_commit , current_result .bad_commit ]:
286
+ hr (80 )
287
+ print ("Commit: {}" .format (commit ))
288
+ checkout_and_build_suite (current_suite , commit )
289
+ for cmd in args .rerun_with_commands .split ("|" ):
290
+ hr (40 )
291
+ mx .run (shlex .split (cmd .strip ()), nonZeroIsFatal = False )
292
+
258
293
send_email (
259
294
bisect_id ,
260
295
email_to ,
0 commit comments