@@ -183,9 +183,9 @@ where
183
183
Ok ( v)
184
184
}
185
185
186
- fn n_benchmarks_remaining ( n : usize ) -> String {
186
+ fn n_normal_benchmarks_remaining ( n : usize ) -> String {
187
187
let suffix = if n == 1 { "" } else { "s" } ;
188
- format ! ( "{} benchmark{} remaining" , n, suffix)
188
+ format ! ( "{} normal benchmark{} remaining" , n, suffix)
189
189
}
190
190
191
191
struct BenchmarkErrors ( usize ) ;
@@ -213,6 +213,7 @@ fn bench(
213
213
artifact_id : & ArtifactId ,
214
214
profile_kinds : & [ ProfileKind ] ,
215
215
scenario_kinds : & [ ScenarioKind ] ,
216
+ bench_rustc : bool ,
216
217
compiler : Compiler < ' _ > ,
217
218
benchmarks : & [ Benchmark ] ,
218
219
iterations : Option < usize > ,
@@ -231,10 +232,13 @@ fn bench(
231
232
}
232
233
}
233
234
234
- let steps = benchmarks
235
+ let mut steps = benchmarks
235
236
. iter ( )
236
237
. map ( |b| b. name . to_string ( ) )
237
238
. collect :: < Vec < _ > > ( ) ;
239
+ if bench_rustc {
240
+ steps. push ( "rustc" . to_string ( ) ) ;
241
+ }
238
242
239
243
// Make sure there is no observable time when the artifact ID is available
240
244
// but the in-progress steps are not.
@@ -249,57 +253,87 @@ fn bench(
249
253
250
254
let start = Instant :: now ( ) ;
251
255
let mut skipped = false ;
252
- for ( nth_benchmark, benchmark) in benchmarks. iter ( ) . enumerate ( ) {
253
- let is_fresh =
254
- rt. block_on ( conn. collector_start_step ( artifact_row_id, & benchmark. name . to_string ( ) ) ) ;
256
+
257
+ let mut measure_and_record = |benchmark_name : & execute:: BenchmarkName ,
258
+ benchmark_supports_stable : bool ,
259
+ print_intro : & dyn Fn ( ) ,
260
+ measure : & dyn Fn (
261
+ & mut execute:: BenchProcessor ,
262
+ ) -> Result < ( ) , anyhow:: Error > | {
263
+ let is_fresh = rt. block_on ( conn. collector_start_step ( artifact_row_id, & benchmark_name. 0 ) ) ;
255
264
if !is_fresh {
256
265
skipped = true ;
257
- eprintln ! ( "skipping {} -- already benchmarked" , benchmark . name ) ;
258
- continue ;
266
+ eprintln ! ( "skipping {} -- already benchmarked" , benchmark_name ) ;
267
+ return ;
259
268
}
260
269
let mut tx = rt. block_on ( conn. transaction ( ) ) ;
261
270
rt. block_on (
262
271
tx. conn ( )
263
- . record_benchmark ( benchmark. name . 0 . as_str ( ) , Some ( benchmark. supports_stable ( ) ) ) ,
264
- ) ;
265
- eprintln ! (
266
- "{}" ,
267
- n_benchmarks_remaining( benchmarks. len( ) - nth_benchmark)
272
+ . record_benchmark ( & benchmark_name. 0 , Some ( benchmark_supports_stable) ) ,
268
273
) ;
274
+ print_intro ( ) ;
269
275
270
276
let mut processor = execute:: BenchProcessor :: new (
271
277
rt,
272
278
tx. conn ( ) ,
273
- & benchmark . name ,
279
+ benchmark_name ,
274
280
& artifact_id,
275
281
artifact_row_id,
276
282
is_self_profile,
277
283
) ;
278
- let result = benchmark. measure (
279
- & mut processor,
280
- profile_kinds,
281
- scenario_kinds,
282
- compiler,
283
- iterations,
284
- ) ;
284
+ let result = measure ( & mut processor) ;
285
285
if let Err ( s) = result {
286
286
eprintln ! (
287
287
"collector error: Failed to benchmark '{}', recorded: {:#}" ,
288
- benchmark . name , s
288
+ benchmark_name , s
289
289
) ;
290
290
errors. incr ( ) ;
291
291
rt. block_on ( tx. conn ( ) . record_error (
292
292
artifact_row_id,
293
- benchmark . name . 0 . as_str ( ) ,
293
+ & benchmark_name . 0 ,
294
294
& format ! ( "{:?}" , s) ,
295
295
) ) ;
296
296
} ;
297
297
rt. block_on (
298
298
tx. conn ( )
299
- . collector_end_step ( artifact_row_id, & benchmark . name . to_string ( ) ) ,
299
+ . collector_end_step ( artifact_row_id, & benchmark_name . 0 ) ,
300
300
) ;
301
301
rt. block_on ( tx. commit ( ) ) . expect ( "committed" ) ;
302
+ } ;
303
+
304
+ // Normal benchmarks.
305
+ for ( nth_benchmark, benchmark) in benchmarks. iter ( ) . enumerate ( ) {
306
+ measure_and_record (
307
+ & benchmark. name ,
308
+ benchmark. supports_stable ( ) ,
309
+ & || {
310
+ eprintln ! (
311
+ "{}" ,
312
+ n_normal_benchmarks_remaining( benchmarks. len( ) - nth_benchmark)
313
+ )
314
+ } ,
315
+ & |processor| {
316
+ benchmark. measure (
317
+ processor,
318
+ profile_kinds,
319
+ scenario_kinds,
320
+ compiler,
321
+ iterations,
322
+ )
323
+ } ,
324
+ )
302
325
}
326
+
327
+ // The special rustc benchmark, if requested.
328
+ if bench_rustc {
329
+ measure_and_record (
330
+ & execute:: BenchmarkName ( "rustc" . to_string ( ) ) ,
331
+ /* supports_stable */ false ,
332
+ & || eprintln ! ( "Special benchmark commencing (due to `--bench-rustc`)" ) ,
333
+ & |processor| processor. measure_rustc ( compiler) . context ( "measure rustc" ) ,
334
+ ) ;
335
+ }
336
+
303
337
let end = start. elapsed ( ) ;
304
338
305
339
eprintln ! (
@@ -373,7 +407,6 @@ fn get_benchmarks(
373
407
374
408
paths. push ( ( path, name) ) ;
375
409
}
376
- paths. push ( ( PathBuf :: from ( "rustc" ) , String :: from ( "rustc" ) ) ) ;
377
410
378
411
let mut includes = include. map ( |list| list. split ( ',' ) . collect :: < HashSet < _ > > ( ) ) ;
379
412
let mut excludes = exclude. map ( |list| list. split ( ',' ) . collect :: < HashSet < _ > > ( ) ) ;
@@ -683,7 +716,7 @@ fn profile(
683
716
check_measureme_installed ( ) . unwrap ( ) ;
684
717
}
685
718
for ( i, benchmark) in benchmarks. iter ( ) . enumerate ( ) {
686
- eprintln ! ( "{}" , n_benchmarks_remaining ( benchmarks. len( ) - i) ) ;
719
+ eprintln ! ( "{}" , n_normal_benchmarks_remaining ( benchmarks. len( ) - i) ) ;
687
720
let mut processor = execute:: ProfileProcessor :: new ( profiler, out_dir, id) ;
688
721
let result = benchmark. measure (
689
722
& mut processor,
@@ -742,6 +775,8 @@ fn main_result() -> anyhow::Result<i32> {
742
775
( @arg INCLUDE : --include +takes_value
743
776
"Include only benchmarks that are listed in\n \
744
777
this comma-separated list of patterns")
778
+ ( @arg BENCH_RUSTC : --( "bench-rustc" )
779
+ "Run the special `rustc` benchmark" )
745
780
( @arg RUNS : --runs +takes_value
746
781
"One or more (comma-separated) of: 'Full',\n \
747
782
'IncrFull', 'IncrUnchanged', 'IncrPatched', 'All'")
@@ -752,13 +787,15 @@ fn main_result() -> anyhow::Result<i32> {
752
787
)
753
788
754
789
( @subcommand bench_next =>
755
- ( about: "Benchmarks the next commit for perf.rust-lang.org" )
790
+ ( about: "Benchmarks the next commit for perf.rust-lang.org, including the special `rustc` benchmark " )
756
791
757
792
// Mandatory arguments
758
793
( @arg SITE_URL : +required +takes_value "Site URL" )
759
794
760
795
// Options
761
796
( @arg DB : --db +takes_value "Database output file" )
797
+ ( @arg BENCH_RUSTC : --( "bench-rustc" )
798
+ "Run the special `rustc` benchmark" )
762
799
( @arg SELF_PROFILE : --( "self-profile" ) "Collect self-profile data" )
763
800
)
764
801
@@ -868,6 +905,7 @@ fn main_result() -> anyhow::Result<i32> {
868
905
let db = sub_m. value_of ( "DB" ) . unwrap_or ( default_db) ;
869
906
let exclude = sub_m. value_of ( "EXCLUDE" ) ;
870
907
let include = sub_m. value_of ( "INCLUDE" ) ;
908
+ let bench_rustc = sub_m. is_present ( "BENCH_RUSTC" ) ;
871
909
let scenario_kinds = scenario_kinds_from_arg ( sub_m. value_of ( "RUNS" ) ) ?;
872
910
let iterations = iterations_from_arg ( sub_m. value_of ( "ITERATIONS" ) ) ?;
873
911
let rustdoc = sub_m. value_of ( "RUSTDOC" ) ;
@@ -886,6 +924,7 @@ fn main_result() -> anyhow::Result<i32> {
886
924
& ArtifactId :: Tag ( id. to_string ( ) ) ,
887
925
& profile_kinds,
888
926
& scenario_kinds,
927
+ bench_rustc,
889
928
Compiler {
890
929
rustc : & rustc,
891
930
rustdoc : rustdoc. as_deref ( ) ,
@@ -907,6 +946,7 @@ fn main_result() -> anyhow::Result<i32> {
907
946
908
947
// Options
909
948
let db = sub_m. value_of ( "DB" ) . unwrap_or ( default_db) ;
949
+ let bench_rustc = sub_m. is_present ( "BENCH_RUSTC" ) ;
910
950
let is_self_profile = sub_m. is_present ( "SELF_PROFILE" ) ;
911
951
912
952
println ! ( "processing commits" ) ;
@@ -941,6 +981,7 @@ fn main_result() -> anyhow::Result<i32> {
941
981
& ArtifactId :: Commit ( commit) ,
942
982
& ProfileKind :: all ( ) ,
943
983
& ScenarioKind :: all ( ) ,
984
+ bench_rustc,
944
985
Compiler :: from_sysroot ( & sysroot) ,
945
986
& benchmarks,
946
987
next. runs . map ( |v| v as usize ) ,
@@ -1011,6 +1052,7 @@ fn main_result() -> anyhow::Result<i32> {
1011
1052
& ArtifactId :: Tag ( toolchain. to_string ( ) ) ,
1012
1053
& proile_kinds,
1013
1054
& scenario_kinds,
1055
+ /* bench_rustc */ false ,
1014
1056
Compiler {
1015
1057
rustc : Path :: new ( rustc. trim ( ) ) ,
1016
1058
rustdoc : Some ( Path :: new ( rustdoc. trim ( ) ) ) ,
0 commit comments