@@ -183,9 +183,9 @@ where
183183 Ok ( v)
184184}
185185
186- fn n_benchmarks_remaining ( n : usize ) -> String {
186+ fn n_normal_benchmarks_remaining ( n : usize ) -> String {
187187 let suffix = if n == 1 { "" } else { "s" } ;
188- format ! ( "{} benchmark{} remaining" , n, suffix)
188+ format ! ( "{} normal benchmark{} remaining" , n, suffix)
189189}
190190
191191struct BenchmarkErrors ( usize ) ;
@@ -213,6 +213,7 @@ fn bench(
213213 artifact_id : & ArtifactId ,
214214 profile_kinds : & [ ProfileKind ] ,
215215 scenario_kinds : & [ ScenarioKind ] ,
216+ bench_rustc : bool ,
216217 compiler : Compiler < ' _ > ,
217218 benchmarks : & [ Benchmark ] ,
218219 iterations : Option < usize > ,
@@ -231,10 +232,13 @@ fn bench(
231232 }
232233 }
233234
234- let steps = benchmarks
235+ let mut steps = benchmarks
235236 . iter ( )
236237 . map ( |b| b. name . to_string ( ) )
237238 . collect :: < Vec < _ > > ( ) ;
239+ if bench_rustc {
240+ steps. push ( "rustc" . to_string ( ) ) ;
241+ }
238242
239243 // Make sure there is no observable time when the artifact ID is available
240244 // but the in-progress steps are not.
@@ -249,57 +253,87 @@ fn bench(
249253
250254 let start = Instant :: now ( ) ;
251255 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 ) ) ;
255264 if !is_fresh {
256265 skipped = true ;
257- eprintln ! ( "skipping {} -- already benchmarked" , benchmark . name ) ;
258- continue ;
266+ eprintln ! ( "skipping {} -- already benchmarked" , benchmark_name ) ;
267+ return ;
259268 }
260269 let mut tx = rt. block_on ( conn. transaction ( ) ) ;
261270 rt. block_on (
262271 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) ) ,
268273 ) ;
274+ print_intro ( ) ;
269275
270276 let mut processor = execute:: BenchProcessor :: new (
271277 rt,
272278 tx. conn ( ) ,
273- & benchmark . name ,
279+ benchmark_name ,
274280 & artifact_id,
275281 artifact_row_id,
276282 is_self_profile,
277283 ) ;
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) ;
285285 if let Err ( s) = result {
286286 eprintln ! (
287287 "collector error: Failed to benchmark '{}', recorded: {:#}" ,
288- benchmark . name , s
288+ benchmark_name , s
289289 ) ;
290290 errors. incr ( ) ;
291291 rt. block_on ( tx. conn ( ) . record_error (
292292 artifact_row_id,
293- benchmark . name . 0 . as_str ( ) ,
293+ & benchmark_name . 0 ,
294294 & format ! ( "{:?}" , s) ,
295295 ) ) ;
296296 } ;
297297 rt. block_on (
298298 tx. conn ( )
299- . collector_end_step ( artifact_row_id, & benchmark . name . to_string ( ) ) ,
299+ . collector_end_step ( artifact_row_id, & benchmark_name . 0 ) ,
300300 ) ;
301301 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+ )
302325 }
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+
303337 let end = start. elapsed ( ) ;
304338
305339 eprintln ! (
@@ -373,7 +407,6 @@ fn get_benchmarks(
373407
374408 paths. push ( ( path, name) ) ;
375409 }
376- paths. push ( ( PathBuf :: from ( "rustc" ) , String :: from ( "rustc" ) ) ) ;
377410
378411 let mut includes = include. map ( |list| list. split ( ',' ) . collect :: < HashSet < _ > > ( ) ) ;
379412 let mut excludes = exclude. map ( |list| list. split ( ',' ) . collect :: < HashSet < _ > > ( ) ) ;
@@ -683,7 +716,7 @@ fn profile(
683716 check_measureme_installed ( ) . unwrap ( ) ;
684717 }
685718 for ( i, benchmark) in benchmarks. iter ( ) . enumerate ( ) {
686- eprintln ! ( "{}" , n_benchmarks_remaining ( benchmarks. len( ) - i) ) ;
719+ eprintln ! ( "{}" , n_normal_benchmarks_remaining ( benchmarks. len( ) - i) ) ;
687720 let mut processor = execute:: ProfileProcessor :: new ( profiler, out_dir, id) ;
688721 let result = benchmark. measure (
689722 & mut processor,
@@ -742,6 +775,8 @@ fn main_result() -> anyhow::Result<i32> {
742775 ( @arg INCLUDE : --include +takes_value
743776 "Include only benchmarks that are listed in\n \
744777 this comma-separated list of patterns")
778+ ( @arg BENCH_RUSTC : --( "bench-rustc" )
779+ "Run the special `rustc` benchmark" )
745780 ( @arg RUNS : --runs +takes_value
746781 "One or more (comma-separated) of: 'Full',\n \
747782 'IncrFull', 'IncrUnchanged', 'IncrPatched', 'All'")
@@ -752,13 +787,15 @@ fn main_result() -> anyhow::Result<i32> {
752787 )
753788
754789 ( @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 " )
756791
757792 // Mandatory arguments
758793 ( @arg SITE_URL : +required +takes_value "Site URL" )
759794
760795 // Options
761796 ( @arg DB : --db +takes_value "Database output file" )
797+ ( @arg BENCH_RUSTC : --( "bench-rustc" )
798+ "Run the special `rustc` benchmark" )
762799 ( @arg SELF_PROFILE : --( "self-profile" ) "Collect self-profile data" )
763800 )
764801
@@ -868,6 +905,7 @@ fn main_result() -> anyhow::Result<i32> {
868905 let db = sub_m. value_of ( "DB" ) . unwrap_or ( default_db) ;
869906 let exclude = sub_m. value_of ( "EXCLUDE" ) ;
870907 let include = sub_m. value_of ( "INCLUDE" ) ;
908+ let bench_rustc = sub_m. is_present ( "BENCH_RUSTC" ) ;
871909 let scenario_kinds = scenario_kinds_from_arg ( sub_m. value_of ( "RUNS" ) ) ?;
872910 let iterations = iterations_from_arg ( sub_m. value_of ( "ITERATIONS" ) ) ?;
873911 let rustdoc = sub_m. value_of ( "RUSTDOC" ) ;
@@ -886,6 +924,7 @@ fn main_result() -> anyhow::Result<i32> {
886924 & ArtifactId :: Tag ( id. to_string ( ) ) ,
887925 & profile_kinds,
888926 & scenario_kinds,
927+ bench_rustc,
889928 Compiler {
890929 rustc : & rustc,
891930 rustdoc : rustdoc. as_deref ( ) ,
@@ -907,6 +946,7 @@ fn main_result() -> anyhow::Result<i32> {
907946
908947 // Options
909948 let db = sub_m. value_of ( "DB" ) . unwrap_or ( default_db) ;
949+ let bench_rustc = sub_m. is_present ( "BENCH_RUSTC" ) ;
910950 let is_self_profile = sub_m. is_present ( "SELF_PROFILE" ) ;
911951
912952 println ! ( "processing commits" ) ;
@@ -941,6 +981,7 @@ fn main_result() -> anyhow::Result<i32> {
941981 & ArtifactId :: Commit ( commit) ,
942982 & ProfileKind :: all ( ) ,
943983 & ScenarioKind :: all ( ) ,
984+ bench_rustc,
944985 Compiler :: from_sysroot ( & sysroot) ,
945986 & benchmarks,
946987 next. runs . map ( |v| v as usize ) ,
@@ -1011,6 +1052,7 @@ fn main_result() -> anyhow::Result<i32> {
10111052 & ArtifactId :: Tag ( toolchain. to_string ( ) ) ,
10121053 & proile_kinds,
10131054 & scenario_kinds,
1055+ /* bench_rustc */ false ,
10141056 Compiler {
10151057 rustc : Path :: new ( rustc. trim ( ) ) ,
10161058 rustdoc : Some ( Path :: new ( rustdoc. trim ( ) ) ) ,
0 commit comments