@@ -62,7 +62,7 @@ use database::{ArtifactId, ArtifactIdNumber, Commit, CommitType, Connection, Poo
62
62
63
63
fn n_normal_benchmarks_remaining ( n : usize ) -> String {
64
64
let suffix = if n == 1 { "" } else { "s" } ;
65
- format ! ( "{} normal benchmark{} remaining" , n , suffix )
65
+ format ! ( "{n } normal benchmark{suffix } remaining" )
66
66
}
67
67
68
68
struct BenchmarkErrors ( usize ) ;
@@ -160,7 +160,7 @@ fn generate_diffs(
160
160
vec ! [ format!( "{:?}" , scenario) ]
161
161
}
162
162
Scenario :: IncrPatched => ( 0 ..benchmark. patches . len ( ) )
163
- . map ( |i| format ! ( "{:?}{}" , scenario , i ) )
163
+ . map ( |i| format ! ( "{scenario :?}{i}" ) )
164
164
. collect :: < Vec < _ > > ( ) ,
165
165
}
166
166
} ) {
@@ -175,15 +175,15 @@ fn generate_diffs(
175
175
profiler. postfix( )
176
176
)
177
177
} ;
178
- let id_diff = format ! ( "{}-{}" , id1 , id2 ) ;
178
+ let id_diff = format ! ( "{id1 }-{id2}" ) ;
179
179
let prefix = profiler. prefix ( ) ;
180
180
let left = out_dir. join ( filename ( prefix, id1) ) ;
181
181
let right = out_dir. join ( filename ( prefix, id2) ) ;
182
182
let output = out_dir. join ( filename ( & format ! ( "{prefix}-diff" ) , & id_diff) ) ;
183
183
184
184
if let Err ( e) = profiler. diff ( & left, & right, & output) {
185
185
errors. incr ( ) ;
186
- eprintln ! ( "collector error: {:?}" , e ) ;
186
+ eprintln ! ( "collector error: {e :?}" ) ;
187
187
continue ;
188
188
}
189
189
@@ -249,7 +249,7 @@ fn main() {
249
249
match main_result ( ) {
250
250
Ok ( code) => process:: exit ( code) ,
251
251
Err ( err) => {
252
- eprintln ! ( "collector error: {:?}" , err ) ;
252
+ eprintln ! ( "collector error: {err :?}" ) ;
253
253
process:: exit ( 1 ) ;
254
254
}
255
255
}
@@ -411,7 +411,7 @@ struct DbOption {
411
411
/// Database output file
412
412
// This would be better as a `PathBuf`, but it's used in various ways that
413
413
// 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" ) ]
415
415
db : String ,
416
416
}
417
417
@@ -668,20 +668,26 @@ enum Commands {
668
668
modified : Option < String > ,
669
669
} ,
670
670
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.
672
673
AddCollector {
673
674
#[ command( flatten) ]
674
675
db : DbOption ,
675
676
677
+ /// Name of the collector.
676
678
#[ arg( long) ]
677
679
collector_name : String ,
678
680
681
+ /// Target tuple which will the collector be benchmarking.
679
682
#[ arg( long) ]
680
683
target : String ,
681
684
685
+ /// Should the collector be marked as active immediately?
686
+ /// Only active collectors will receive jobs.
682
687
#[ arg( long) ]
683
688
is_active : bool ,
684
689
690
+ /// The benchmark set index that the collector will be benchmarking.
685
691
#[ arg( long) ]
686
692
benchmark_set : u32 ,
687
693
} ,
@@ -766,14 +772,15 @@ fn main_result() -> anyhow::Result<i32> {
766
772
runtime : & runtime_benchmark_dir,
767
773
} ;
768
774
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 ) ;
771
778
772
779
match args. command {
773
780
Commands :: BinaryStats { mode, symbols } => {
774
781
match mode {
775
782
BinaryStatsMode :: Compile ( args) => {
776
- binary_stats_compile ( args, symbols, & target_triple ) ?;
783
+ binary_stats_compile ( args, symbols, & host_target_tuple ) ?;
777
784
}
778
785
BinaryStatsMode :: Local ( args) => {
779
786
binary_stats_local ( args, symbols) ?;
@@ -792,7 +799,7 @@ fn main_result() -> anyhow::Result<i32> {
792
799
purge,
793
800
} => {
794
801
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 ) ?;
796
803
let pool = Pool :: open ( & db. db ) ;
797
804
798
805
let isolation_mode = if no_isolate {
@@ -846,7 +853,7 @@ fn main_result() -> anyhow::Result<i32> {
846
853
rustc,
847
854
ToolchainConfig :: default ( ) ,
848
855
id,
849
- target_triple . clone ( ) ,
856
+ host_target_tuple . clone ( ) ,
850
857
) ?;
851
858
let suite = prepare_runtime_benchmark_suite (
852
859
& toolchain,
@@ -903,7 +910,7 @@ fn main_result() -> anyhow::Result<i32> {
903
910
rustc,
904
911
ToolchainConfig :: default ( ) ,
905
912
id,
906
- target_triple . clone ( ) ,
913
+ host_target_tuple . clone ( ) ,
907
914
) ?;
908
915
Ok :: < _ , anyhow:: Error > ( toolchain)
909
916
} ;
@@ -946,7 +953,7 @@ fn main_result() -> anyhow::Result<i32> {
946
953
. cargo ( local. cargo . as_deref ( ) , local. cargo_config . as_slice ( ) )
947
954
. id ( local. id . as_deref ( ) ) ,
948
955
"" ,
949
- target_triple ,
956
+ host_target_tuple ,
950
957
) ?;
951
958
952
959
let mut benchmarks = get_compile_benchmarks ( & compile_benchmark_dir, ( & local) . into ( ) ) ?;
@@ -991,7 +998,7 @@ fn main_result() -> anyhow::Result<i32> {
991
998
println ! ( "processing artifacts" ) ;
992
999
let client = reqwest:: blocking:: Client :: new ( ) ;
993
1000
let response: collector:: api:: next_artifact:: Response = client
994
- . get ( format ! ( "{}/perf/next_artifact" , site_url ) )
1001
+ . get ( format ! ( "{site_url }/perf/next_artifact" ) )
995
1002
. send ( ) ?
996
1003
. json ( ) ?;
997
1004
let next = if let Some ( c) = response. artifact {
@@ -1015,7 +1022,7 @@ fn main_result() -> anyhow::Result<i32> {
1015
1022
match next {
1016
1023
NextArtifact :: Release ( tag) => {
1017
1024
let toolchain =
1018
- create_toolchain_from_published_version ( & tag, & target_triple ) ?;
1025
+ create_toolchain_from_published_version ( & tag, & host_target_tuple ) ?;
1019
1026
let conn = rt. block_on ( pool. connection ( ) ) ;
1020
1027
rt. block_on ( bench_published_artifact ( conn, toolchain, & benchmark_dirs) )
1021
1028
}
@@ -1055,10 +1062,9 @@ fn main_result() -> anyhow::Result<i32> {
1055
1062
}
1056
1063
} ;
1057
1064
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:?}" ) ) ?;
1062
1068
1063
1069
let mut benchmarks = get_compile_benchmarks (
1064
1070
& compile_benchmark_dir,
@@ -1118,7 +1124,7 @@ fn main_result() -> anyhow::Result<i32> {
1118
1124
}
1119
1125
} ) ;
1120
1126
// 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 ( ) ?;
1122
1128
1123
1129
match res {
1124
1130
Ok ( res) => res?,
@@ -1134,7 +1140,8 @@ fn main_result() -> anyhow::Result<i32> {
1134
1140
let pool = database:: Pool :: open ( & db. db ) ;
1135
1141
let rt = build_async_runtime ( ) ;
1136
1142
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) ?;
1138
1145
rt. block_on ( bench_published_artifact ( conn, toolchain, & benchmark_dirs) ) ?;
1139
1146
Ok ( 0 )
1140
1147
}
@@ -1182,7 +1189,7 @@ fn main_result() -> anyhow::Result<i32> {
1182
1189
. cargo ( local. cargo . as_deref ( ) , local. cargo_config . as_slice ( ) )
1183
1190
. id ( local. id . as_deref ( ) ) ,
1184
1191
suffix,
1185
- target_triple . clone ( ) ,
1192
+ host_target_tuple . clone ( ) ,
1186
1193
) ?;
1187
1194
let id = toolchain. id . clone ( ) ;
1188
1195
profile_compile (
@@ -1245,7 +1252,13 @@ fn main_result() -> anyhow::Result<i32> {
1245
1252
let last_sha = String :: from_utf8 ( last_sha. stdout ) . expect ( "utf8" ) ;
1246
1253
let last_sha = last_sha. split_whitespace ( ) . next ( ) . expect ( & last_sha) ;
1247
1254
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
+ ) ) ?;
1249
1262
sysroot. preserve ( ) ; // don't delete it
1250
1263
1251
1264
// 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
1313
1326
let target = database:: Target :: from_str ( & target) . map_err ( |e| anyhow:: anyhow!( e) ) ?;
1314
1327
rt. block_on ( conn. add_collector_config (
1315
1328
& collector_name,
1316
- & target,
1329
+ target,
1317
1330
benchmark_set,
1318
1331
is_active,
1319
1332
) ) ?;
@@ -1331,8 +1344,9 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
1331
1344
1332
1345
// Obtain the configuration and validate that it matches the
1333
1346
// 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 ( ) ;
1336
1350
1337
1351
let collector_target = collector_config. target ( ) ;
1338
1352
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
1350
1364
1351
1365
if let Some ( benchmark_job) = benchmark_job {
1352
1366
// TODO; process the job
1353
- println ! ( "{:?}" , benchmark_job ) ;
1367
+ println ! ( "{benchmark_job :?}" ) ;
1354
1368
}
1355
1369
1356
1370
Ok ( 0 )
@@ -1642,7 +1656,7 @@ fn print_binary_stats(
1642
1656
. corner_top_right ( '│' ) ,
1643
1657
) ,
1644
1658
) ;
1645
- println ! ( "{}" , table ) ;
1659
+ println ! ( "{table}" ) ;
1646
1660
}
1647
1661
1648
1662
fn get_local_toolchain_for_runtime_benchmarks (
@@ -1912,16 +1926,13 @@ async fn bench_compile(
1912
1926
) ;
1913
1927
let result = measure ( & mut processor) . await ;
1914
1928
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:#}" ) ;
1919
1930
errors. incr ( ) ;
1920
1931
tx. conn ( )
1921
1932
. record_error (
1922
1933
collector. artifact_row_id ,
1923
1934
& benchmark_name. 0 ,
1924
- & format ! ( "{:?}" , s ) ,
1935
+ & format ! ( "{s :?}" ) ,
1925
1936
)
1926
1937
. await ;
1927
1938
} ;
0 commit comments