@@ -62,7 +62,7 @@ use database::{ArtifactId, ArtifactIdNumber, Commit, CommitType, Connection, Poo
6262
6363fn n_normal_benchmarks_remaining ( n : usize ) -> String {
6464 let suffix = if n == 1 { "" } else { "s" } ;
65- format ! ( "{} normal benchmark{} remaining" , n , suffix )
65+ format ! ( "{n } normal benchmark{suffix } remaining" )
6666}
6767
6868struct BenchmarkErrors ( usize ) ;
@@ -160,7 +160,7 @@ fn generate_diffs(
160160 vec ! [ format!( "{:?}" , scenario) ]
161161 }
162162 Scenario :: IncrPatched => ( 0 ..benchmark. patches . len ( ) )
163- . map ( |i| format ! ( "{:?}{}" , scenario , i ) )
163+ . map ( |i| format ! ( "{scenario :?}{i}" ) )
164164 . collect :: < Vec < _ > > ( ) ,
165165 }
166166 } ) {
@@ -175,15 +175,15 @@ fn generate_diffs(
175175 profiler. postfix( )
176176 )
177177 } ;
178- let id_diff = format ! ( "{}-{}" , id1 , id2 ) ;
178+ let id_diff = format ! ( "{id1 }-{id2}" ) ;
179179 let prefix = profiler. prefix ( ) ;
180180 let left = out_dir. join ( filename ( prefix, id1) ) ;
181181 let right = out_dir. join ( filename ( prefix, id2) ) ;
182182 let output = out_dir. join ( filename ( & format ! ( "{prefix}-diff" ) , & id_diff) ) ;
183183
184184 if let Err ( e) = profiler. diff ( & left, & right, & output) {
185185 errors. incr ( ) ;
186- eprintln ! ( "collector error: {:?}" , e ) ;
186+ eprintln ! ( "collector error: {e :?}" ) ;
187187 continue ;
188188 }
189189
@@ -249,7 +249,7 @@ fn main() {
249249 match main_result ( ) {
250250 Ok ( code) => process:: exit ( code) ,
251251 Err ( err) => {
252- eprintln ! ( "collector error: {:?}" , err ) ;
252+ eprintln ! ( "collector error: {err :?}" ) ;
253253 process:: exit ( 1 ) ;
254254 }
255255 }
@@ -411,7 +411,7 @@ struct DbOption {
411411 /// Database output file
412412 // This would be better as a `PathBuf`, but it's used in various ways that
413413 // make that tricky without adjusting several points in the code.
414- #[ arg( long, default_value = "results.db" ) ]
414+ #[ arg( long, default_value = "results.db" , env = "DATABASE_URL" ) ]
415415 db : String ,
416416}
417417
@@ -668,20 +668,26 @@ enum Commands {
668668 modified : Option < String > ,
669669 } ,
670670
671- /// Registers a collector in the database
671+ /// Registers a new collector in the database.
672+ /// Use `--is_active` to immediately mark the collector as active.
672673 AddCollector {
673674 #[ command( flatten) ]
674675 db : DbOption ,
675676
677+ /// Name of the collector.
676678 #[ arg( long) ]
677679 collector_name : String ,
678680
681+ /// Target tuple which will the collector be benchmarking.
679682 #[ arg( long) ]
680683 target : String ,
681684
685+ /// Should the collector be marked as active immediately?
686+ /// Only active collectors will receive jobs.
682687 #[ arg( long) ]
683688 is_active : bool ,
684689
690+ /// The benchmark set index that the collector will be benchmarking.
685691 #[ arg( long) ]
686692 benchmark_set : u32 ,
687693 } ,
@@ -766,14 +772,15 @@ fn main_result() -> anyhow::Result<i32> {
766772 runtime : & runtime_benchmark_dir,
767773 } ;
768774
769- // XXX: This doesn't necessarily work for all archs
770- let target_triple = format ! ( "{}-unknown-linux-gnu" , std:: env:: consts:: ARCH ) ;
775+ // This clearly won't work for all architectures, but should be good enough for x64 Linux
776+ // and ARM 64-bit Linux.
777+ let host_target_tuple = format ! ( "{}-unknown-linux-gnu" , std:: env:: consts:: ARCH ) ;
771778
772779 match args. command {
773780 Commands :: BinaryStats { mode, symbols } => {
774781 match mode {
775782 BinaryStatsMode :: Compile ( args) => {
776- binary_stats_compile ( args, symbols, & target_triple ) ?;
783+ binary_stats_compile ( args, symbols, & host_target_tuple ) ?;
777784 }
778785 BinaryStatsMode :: Local ( args) => {
779786 binary_stats_local ( args, symbols) ?;
@@ -792,7 +799,7 @@ fn main_result() -> anyhow::Result<i32> {
792799 purge,
793800 } => {
794801 log_db ( & db) ;
795- let toolchain = get_local_toolchain_for_runtime_benchmarks ( & local, & target_triple ) ?;
802+ let toolchain = get_local_toolchain_for_runtime_benchmarks ( & local, & host_target_tuple ) ?;
796803 let pool = Pool :: open ( & db. db ) ;
797804
798805 let isolation_mode = if no_isolate {
@@ -846,7 +853,7 @@ fn main_result() -> anyhow::Result<i32> {
846853 rustc,
847854 ToolchainConfig :: default ( ) ,
848855 id,
849- target_triple . clone ( ) ,
856+ host_target_tuple . clone ( ) ,
850857 ) ?;
851858 let suite = prepare_runtime_benchmark_suite (
852859 & toolchain,
@@ -903,7 +910,7 @@ fn main_result() -> anyhow::Result<i32> {
903910 rustc,
904911 ToolchainConfig :: default ( ) ,
905912 id,
906- target_triple . clone ( ) ,
913+ host_target_tuple . clone ( ) ,
907914 ) ?;
908915 Ok :: < _ , anyhow:: Error > ( toolchain)
909916 } ;
@@ -946,7 +953,7 @@ fn main_result() -> anyhow::Result<i32> {
946953 . cargo ( local. cargo . as_deref ( ) , local. cargo_config . as_slice ( ) )
947954 . id ( local. id . as_deref ( ) ) ,
948955 "" ,
949- target_triple ,
956+ host_target_tuple ,
950957 ) ?;
951958
952959 let mut benchmarks = get_compile_benchmarks ( & compile_benchmark_dir, ( & local) . into ( ) ) ?;
@@ -991,7 +998,7 @@ fn main_result() -> anyhow::Result<i32> {
991998 println ! ( "processing artifacts" ) ;
992999 let client = reqwest:: blocking:: Client :: new ( ) ;
9931000 let response: collector:: api:: next_artifact:: Response = client
994- . get ( format ! ( "{}/perf/next_artifact" , site_url ) )
1001+ . get ( format ! ( "{site_url }/perf/next_artifact" ) )
9951002 . send ( ) ?
9961003 . json ( ) ?;
9971004 let next = if let Some ( c) = response. artifact {
@@ -1015,7 +1022,7 @@ fn main_result() -> anyhow::Result<i32> {
10151022 match next {
10161023 NextArtifact :: Release ( tag) => {
10171024 let toolchain =
1018- create_toolchain_from_published_version ( & tag, & target_triple ) ?;
1025+ create_toolchain_from_published_version ( & tag, & host_target_tuple ) ?;
10191026 let conn = rt. block_on ( pool. connection ( ) ) ;
10201027 rt. block_on ( bench_published_artifact ( conn, toolchain, & benchmark_dirs) )
10211028 }
@@ -1055,10 +1062,9 @@ fn main_result() -> anyhow::Result<i32> {
10551062 }
10561063 } ;
10571064 let sha = commit. sha . to_string ( ) ;
1058- let sysroot = Sysroot :: install ( sha. clone ( ) , & target_triple, & backends)
1059- . with_context ( || {
1060- format ! ( "failed to install sysroot for {:?}" , commit)
1061- } ) ?;
1065+ let sysroot = rt
1066+ . block_on ( Sysroot :: install ( sha. clone ( ) , & host_target_tuple, & backends) )
1067+ . with_context ( || format ! ( "failed to install sysroot for {commit:?}" ) ) ?;
10621068
10631069 let mut benchmarks = get_compile_benchmarks (
10641070 & compile_benchmark_dir,
@@ -1118,7 +1124,7 @@ fn main_result() -> anyhow::Result<i32> {
11181124 }
11191125 } ) ;
11201126 // We need to send a message to this endpoint even if the collector panics
1121- client. post ( format ! ( "{}/perf/onpush" , site_url ) ) . send ( ) ?;
1127+ client. post ( format ! ( "{site_url }/perf/onpush" ) ) . send ( ) ?;
11221128
11231129 match res {
11241130 Ok ( res) => res?,
@@ -1134,7 +1140,8 @@ fn main_result() -> anyhow::Result<i32> {
11341140 let pool = database:: Pool :: open ( & db. db ) ;
11351141 let rt = build_async_runtime ( ) ;
11361142 let conn = rt. block_on ( pool. connection ( ) ) ;
1137- let toolchain = create_toolchain_from_published_version ( & toolchain, & target_triple) ?;
1143+ let toolchain =
1144+ create_toolchain_from_published_version ( & toolchain, & host_target_tuple) ?;
11381145 rt. block_on ( bench_published_artifact ( conn, toolchain, & benchmark_dirs) ) ?;
11391146 Ok ( 0 )
11401147 }
@@ -1182,7 +1189,7 @@ fn main_result() -> anyhow::Result<i32> {
11821189 . cargo ( local. cargo . as_deref ( ) , local. cargo_config . as_slice ( ) )
11831190 . id ( local. id . as_deref ( ) ) ,
11841191 suffix,
1185- target_triple . clone ( ) ,
1192+ host_target_tuple . clone ( ) ,
11861193 ) ?;
11871194 let id = toolchain. id . clone ( ) ;
11881195 profile_compile (
@@ -1245,7 +1252,13 @@ fn main_result() -> anyhow::Result<i32> {
12451252 let last_sha = String :: from_utf8 ( last_sha. stdout ) . expect ( "utf8" ) ;
12461253 let last_sha = last_sha. split_whitespace ( ) . next ( ) . expect ( & last_sha) ;
12471254 let commit = get_commit_or_fake_it ( last_sha) . expect ( "success" ) ;
1248- let mut sysroot = Sysroot :: install ( commit. sha , & target_triple, & codegen_backends. 0 ) ?;
1255+
1256+ let rt = build_async_runtime ( ) ;
1257+ let mut sysroot = rt. block_on ( Sysroot :: install (
1258+ commit. sha ,
1259+ & host_target_tuple,
1260+ & codegen_backends. 0 ,
1261+ ) ) ?;
12491262 sysroot. preserve ( ) ; // don't delete it
12501263
12511264 // Print the directory containing the toolchain.
@@ -1313,7 +1326,7 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
13131326 let target = database:: Target :: from_str ( & target) . map_err ( |e| anyhow:: anyhow!( e) ) ?;
13141327 rt. block_on ( conn. add_collector_config (
13151328 & collector_name,
1316- & target,
1329+ target,
13171330 benchmark_set,
13181331 is_active,
13191332 ) ) ?;
@@ -1331,8 +1344,9 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
13311344
13321345 // Obtain the configuration and validate that it matches the
13331346 // collector's setup
1334- let collector_config: database:: CollectorConfig =
1335- rt. block_on ( conn. get_collector_config ( & collector_name) ) ?;
1347+ let collector_config: database:: CollectorConfig = rt
1348+ . block_on ( conn. get_collector_config ( & collector_name) ) ?
1349+ . unwrap ( ) ;
13361350
13371351 let collector_target = collector_config. target ( ) ;
13381352 if collector_target. as_str ( ) != target {
@@ -1350,7 +1364,7 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
13501364
13511365 if let Some ( benchmark_job) = benchmark_job {
13521366 // TODO; process the job
1353- println ! ( "{:?}" , benchmark_job ) ;
1367+ println ! ( "{benchmark_job :?}" ) ;
13541368 }
13551369
13561370 Ok ( 0 )
@@ -1642,7 +1656,7 @@ fn print_binary_stats(
16421656 . corner_top_right ( '│' ) ,
16431657 ) ,
16441658 ) ;
1645- println ! ( "{}" , table ) ;
1659+ println ! ( "{table}" ) ;
16461660}
16471661
16481662fn get_local_toolchain_for_runtime_benchmarks (
@@ -1912,16 +1926,13 @@ async fn bench_compile(
19121926 ) ;
19131927 let result = measure ( & mut processor) . await ;
19141928 if let Err ( s) = result {
1915- eprintln ! (
1916- "collector error: Failed to benchmark '{}', recorded: {:#}" ,
1917- benchmark_name, s
1918- ) ;
1929+ eprintln ! ( "collector error: Failed to benchmark '{benchmark_name}', recorded: {s:#}" ) ;
19191930 errors. incr ( ) ;
19201931 tx. conn ( )
19211932 . record_error (
19221933 collector. artifact_row_id ,
19231934 & benchmark_name. 0 ,
1924- & format ! ( "{:?}" , s ) ,
1935+ & format ! ( "{s :?}" ) ,
19251936 )
19261937 . await ;
19271938 } ;
0 commit comments