1
1
use crate :: compile:: benchmark:: category:: Category ;
2
+ use crate :: compile:: benchmark:: codegen_backend:: CodegenBackend ;
2
3
use crate :: compile:: benchmark:: patch:: Patch ;
3
4
use crate :: compile:: benchmark:: profile:: Profile ;
4
5
use crate :: compile:: benchmark:: scenario:: Scenario ;
@@ -178,6 +179,7 @@ impl Benchmark {
178
179
toolchain : & ' a Toolchain ,
179
180
cwd : & ' a Path ,
180
181
profile : Profile ,
182
+ backend : CodegenBackend ,
181
183
) -> CargoProcess < ' a > {
182
184
let mut cargo_args = self
183
185
. config
@@ -199,6 +201,7 @@ impl Benchmark {
199
201
processor_name : self . name . clone ( ) ,
200
202
cwd,
201
203
profile,
204
+ backend,
202
205
incremental : false ,
203
206
processor_etc : None ,
204
207
manifest_path : self
@@ -226,6 +229,7 @@ impl Benchmark {
226
229
processor : & mut dyn Processor ,
227
230
profiles : & [ Profile ] ,
228
231
scenarios : & [ Scenario ] ,
232
+ backends : & [ CodegenBackend ] ,
229
233
toolchain : & Toolchain ,
230
234
iterations : Option < usize > ,
231
235
) -> anyhow:: Result < ( ) > {
@@ -293,11 +297,17 @@ impl Benchmark {
293
297
for ( profile, prep_dir) in & profile_dirs {
294
298
let server = server. clone ( ) ;
295
299
let thread = s. spawn :: < _ , anyhow:: Result < ( ) > > ( move || {
296
- wait_for_future (
297
- self . mk_cargo_process ( toolchain, prep_dir. path ( ) , * profile)
298
- . jobserver ( server)
299
- . run_rustc ( false ) ,
300
- ) ?;
300
+ wait_for_future ( async move {
301
+ // Prepare all backend artifacts into the same target directory
302
+ for backend in backends {
303
+ let server = server. clone ( ) ;
304
+ self . mk_cargo_process ( toolchain, prep_dir. path ( ) , * profile, * backend)
305
+ . jobserver ( server)
306
+ . run_rustc ( false )
307
+ . await ?;
308
+ }
309
+ Ok :: < ( ) , anyhow:: Error > ( ( ) )
310
+ } ) ?;
301
311
Ok ( ( ) )
302
312
} ) ;
303
313
threads. push ( thread) ;
@@ -320,77 +330,88 @@ impl Benchmark {
320
330
preparation_start. elapsed( ) . as_secs( )
321
331
) ;
322
332
323
- for ( profile, prep_dir) in profile_dirs {
324
- eprintln ! ( "Running {}: {:?} + {:?}" , self . name, profile, scenarios) ;
325
-
326
- // We want at least two runs for all benchmarks (since we run
327
- // self-profile separately).
328
- processor. start_first_collection ( ) ;
329
- for i in 0 ..std:: cmp:: max ( iterations, 2 ) {
330
- if i == 1 {
331
- let different = processor. finished_first_collection ( ) ;
332
- if iterations == 1 && !different {
333
- // Don't run twice if this processor doesn't need it and
334
- // we've only been asked to run once.
335
- break ;
336
- }
337
- }
338
- log:: debug!( "Benchmark iteration {}/{}" , i + 1 , iterations) ;
339
- // Don't delete the directory on error.
340
- let timing_dir = ManuallyDrop :: new ( self . make_temp_dir ( prep_dir. path ( ) ) ?) ;
341
- let cwd = timing_dir. path ( ) ;
342
-
343
- // A full non-incremental build.
344
- if scenarios. contains ( & Scenario :: Full ) {
345
- self . mk_cargo_process ( toolchain, cwd, profile)
346
- . processor ( processor, Scenario :: Full , "Full" , None )
347
- . run_rustc ( true )
348
- . await ?;
349
- }
333
+ for & backend in backends {
334
+ for ( profile, prep_dir) in & profile_dirs {
335
+ let profile = * profile;
336
+ eprintln ! (
337
+ "Running {}: {:?} + {:?} + {:?}" ,
338
+ self . name, profile, scenarios, backend
339
+ ) ;
350
340
351
- // Rustdoc does not support incremental compilation
352
- if profile != Profile :: Doc {
353
- // An incremental from scratch (slowest incremental case).
354
- // This is required for any subsequent incremental builds.
355
- if scenarios. iter ( ) . any ( |s| s. is_incr ( ) ) {
356
- self . mk_cargo_process ( toolchain, cwd, profile)
357
- . incremental ( true )
358
- . processor ( processor, Scenario :: IncrFull , "IncrFull" , None )
359
- . run_rustc ( true )
360
- . await ?;
341
+ // We want at least two runs for all benchmarks (since we run
342
+ // self-profile separately).
343
+ processor. start_first_collection ( ) ;
344
+ for i in 0 ..std:: cmp:: max ( iterations, 2 ) {
345
+ if i == 1 {
346
+ let different = processor. finished_first_collection ( ) ;
347
+ if iterations == 1 && !different {
348
+ // Don't run twice if this processor doesn't need it and
349
+ // we've only been asked to run once.
350
+ break ;
351
+ }
361
352
}
362
-
363
- // An incremental build with no changes (fastest incremental case).
364
- if scenarios. contains ( & Scenario :: IncrUnchanged ) {
365
- self . mk_cargo_process ( toolchain, cwd, profile)
366
- . incremental ( true )
367
- . processor ( processor, Scenario :: IncrUnchanged , "IncrUnchanged" , None )
353
+ log:: debug!( "Benchmark iteration {}/{}" , i + 1 , iterations) ;
354
+ // Don't delete the directory on error.
355
+ let timing_dir = ManuallyDrop :: new ( self . make_temp_dir ( prep_dir. path ( ) ) ?) ;
356
+ let cwd = timing_dir. path ( ) ;
357
+
358
+ // A full non-incremental build.
359
+ if scenarios. contains ( & Scenario :: Full ) {
360
+ self . mk_cargo_process ( toolchain, cwd, profile, backend)
361
+ . processor ( processor, Scenario :: Full , "Full" , None )
368
362
. run_rustc ( true )
369
363
. await ?;
370
364
}
371
365
372
- if scenarios. contains ( & Scenario :: IncrPatched ) {
373
- for ( i, patch) in self . patches . iter ( ) . enumerate ( ) {
374
- log:: debug!( "applying patch {}" , patch. name) ;
375
- patch. apply ( cwd) . map_err ( |s| anyhow:: anyhow!( "{}" , s) ) ?;
366
+ // Rustdoc does not support incremental compilation
367
+ if profile != Profile :: Doc {
368
+ // An incremental from scratch (slowest incremental case).
369
+ // This is required for any subsequent incremental builds.
370
+ if scenarios. iter ( ) . any ( |s| s. is_incr ( ) ) {
371
+ self . mk_cargo_process ( toolchain, cwd, profile, backend)
372
+ . incremental ( true )
373
+ . processor ( processor, Scenario :: IncrFull , "IncrFull" , None )
374
+ . run_rustc ( true )
375
+ . await ?;
376
+ }
376
377
377
- // An incremental build with some changes (realistic
378
- // incremental case).
379
- let scenario_str = format ! ( "IncrPatched{}" , i) ;
380
- self . mk_cargo_process ( toolchain, cwd, profile)
378
+ // An incremental build with no changes (fastest incremental case).
379
+ if scenarios. contains ( & Scenario :: IncrUnchanged ) {
380
+ self . mk_cargo_process ( toolchain, cwd, profile, backend)
381
381
. incremental ( true )
382
382
. processor (
383
383
processor,
384
- Scenario :: IncrPatched ,
385
- & scenario_str ,
386
- Some ( patch ) ,
384
+ Scenario :: IncrUnchanged ,
385
+ "IncrUnchanged" ,
386
+ None ,
387
387
)
388
388
. run_rustc ( true )
389
389
. await ?;
390
390
}
391
+
392
+ if scenarios. contains ( & Scenario :: IncrPatched ) {
393
+ for ( i, patch) in self . patches . iter ( ) . enumerate ( ) {
394
+ log:: debug!( "applying patch {}" , patch. name) ;
395
+ patch. apply ( cwd) . map_err ( |s| anyhow:: anyhow!( "{}" , s) ) ?;
396
+
397
+ // An incremental build with some changes (realistic
398
+ // incremental case).
399
+ let scenario_str = format ! ( "IncrPatched{}" , i) ;
400
+ self . mk_cargo_process ( toolchain, cwd, profile, backend)
401
+ . incremental ( true )
402
+ . processor (
403
+ processor,
404
+ Scenario :: IncrPatched ,
405
+ & scenario_str,
406
+ Some ( patch) ,
407
+ )
408
+ . run_rustc ( true )
409
+ . await ?;
410
+ }
411
+ }
391
412
}
413
+ drop ( ManuallyDrop :: into_inner ( timing_dir) ) ;
392
414
}
393
- drop ( ManuallyDrop :: into_inner ( timing_dir) ) ;
394
415
}
395
416
}
396
417
0 commit comments