@@ -13,6 +13,7 @@ use collector::benchmark::{
13
13
use collector:: { runtime, utils, CollectorCtx , CollectorStepBuilder } ;
14
14
use database:: { ArtifactId , Commit , CommitType , Connection , Pool } ;
15
15
use rayon:: iter:: { IndexedParallelIterator , IntoParallelRefIterator , ParallelIterator } ;
16
+ use std:: cmp:: Ordering ;
16
17
use std:: ffi:: OsStr ;
17
18
use std:: fs;
18
19
use std:: fs:: File ;
@@ -57,6 +58,7 @@ impl BenchmarkErrors {
57
58
}
58
59
}
59
60
61
+ #[ allow( clippy:: too_many_arguments) ]
60
62
fn bench (
61
63
rt : & mut Runtime ,
62
64
mut conn : Box < dyn Connection > ,
@@ -326,6 +328,7 @@ fn cg_annotate(cgout: &Path, path: &Path) -> anyhow::Result<()> {
326
328
Ok ( ( ) )
327
329
}
328
330
331
+ #[ allow( clippy:: too_many_arguments) ]
329
332
fn profile (
330
333
compiler : Compiler ,
331
334
id : & str ,
@@ -348,8 +351,7 @@ fn profile(
348
351
let benchmark_id = format ! ( "{} ({}/{})" , benchmark. name, i + 1 , benchmarks. len( ) ) ;
349
352
eprintln ! ( "Executing benchmark {benchmark_id}" ) ;
350
353
let mut processor = ProfileProcessor :: new ( profiler, out_dir, id) ;
351
- let result =
352
- benchmark. measure ( & mut processor, & profiles, & scenarios, compiler, Some ( 1 ) ) ;
354
+ let result = benchmark. measure ( & mut processor, profiles, scenarios, compiler, Some ( 1 ) ) ;
353
355
eprintln ! ( "Finished benchmark {benchmark_id}" ) ;
354
356
355
357
if let Err ( ref s) = result {
@@ -400,7 +402,7 @@ impl TypedValueParser for ProfileArgParser {
400
402
let profiles: Result < Vec < Profile > , _ > = value
401
403
. to_str ( )
402
404
. unwrap ( )
403
- . split ( "," )
405
+ . split ( ',' )
404
406
. map ( |item| clap:: value_parser!( Profile ) . parse_ref ( cmd, arg, OsStr :: new ( item) ) )
405
407
. collect ( ) ;
406
408
@@ -410,7 +412,7 @@ impl TypedValueParser for ProfileArgParser {
410
412
411
413
fn possible_values ( & self ) -> Option < Box < dyn Iterator < Item = PossibleValue > + ' _ > > {
412
414
let values = Profile :: value_variants ( )
413
- . into_iter ( )
415
+ . iter ( )
414
416
. filter_map ( |item| item. to_possible_value ( ) )
415
417
. chain ( [ PossibleValue :: new ( "All" ) ] ) ;
416
418
Some ( Box :: new ( values) )
@@ -438,7 +440,7 @@ impl TypedValueParser for ScenarioArgParser {
438
440
let scenarios: Result < Vec < Scenario > , _ > = value
439
441
. to_str ( )
440
442
. unwrap ( )
441
- . split ( "," )
443
+ . split ( ',' )
442
444
. map ( |item| clap:: value_parser!( Scenario ) . parse_ref ( cmd, arg, OsStr :: new ( item) ) )
443
445
. collect ( ) ;
444
446
@@ -448,7 +450,7 @@ impl TypedValueParser for ScenarioArgParser {
448
450
449
451
fn possible_values ( & self ) -> Option < Box < dyn Iterator < Item = PossibleValue > + ' _ > > {
450
452
let values = Scenario :: value_variants ( )
451
- . into_iter ( )
453
+ . iter ( )
452
454
. filter_map ( |item| item. to_possible_value ( ) )
453
455
. chain ( [ PossibleValue :: new ( "All" ) ] ) ;
454
456
Some ( Box :: new ( values) )
@@ -711,7 +713,7 @@ fn main_result() -> anyhow::Result<i32> {
711
713
let pool = Pool :: open ( & db. db ) ;
712
714
713
715
let suite = runtime:: discover_benchmarks ( & toolchain, & runtime_benchmark_dir) ?;
714
- let artifact_id = ArtifactId :: Tag ( toolchain. id . clone ( ) ) ;
716
+ let artifact_id = ArtifactId :: Tag ( toolchain. id ) ;
715
717
let ( conn, collector) = rt. block_on ( async {
716
718
let mut conn = pool. connection ( ) . await ;
717
719
let collector = CollectorStepBuilder :: default ( )
@@ -744,7 +746,7 @@ fn main_result() -> anyhow::Result<i32> {
744
746
let pool = database:: Pool :: open ( & db. db ) ;
745
747
746
748
let toolchain = get_local_toolchain (
747
- & profiles,
749
+ profiles,
748
750
& local. rustc ,
749
751
opts. rustdoc . as_deref ( ) ,
750
752
local. cargo . as_deref ( ) ,
@@ -771,8 +773,8 @@ fn main_result() -> anyhow::Result<i32> {
771
773
let res = bench (
772
774
& mut rt,
773
775
conn,
774
- & profiles,
775
- & scenarios,
776
+ profiles,
777
+ scenarios,
776
778
Compiler :: from_toolchain ( & toolchain, & target_triple) ,
777
779
& benchmarks,
778
780
Some ( iterations) ,
@@ -792,7 +794,7 @@ fn main_result() -> anyhow::Result<i32> {
792
794
println ! ( "processing artifacts" ) ;
793
795
let client = reqwest:: blocking:: Client :: new ( ) ;
794
796
let response: collector:: api:: next_artifact:: Response = client
795
- . get ( & format ! ( "{}/perf/next_artifact" , site_url) )
797
+ . get ( format ! ( "{}/perf/next_artifact" , site_url) )
796
798
. send ( ) ?
797
799
. json ( ) ?;
798
800
let next = if let Some ( c) = response. artifact {
@@ -815,7 +817,7 @@ fn main_result() -> anyhow::Result<i32> {
815
817
& compile_benchmark_dir,
816
818
) ?;
817
819
818
- client. post ( & format ! ( "{}/perf/onpush" , site_url) ) . send ( ) ?;
820
+ client. post ( format ! ( "{}/perf/onpush" , site_url) ) . send ( ) ?;
819
821
}
820
822
NextArtifact :: Commit {
821
823
commit,
@@ -853,7 +855,7 @@ fn main_result() -> anyhow::Result<i32> {
853
855
collector,
854
856
) ;
855
857
856
- client. post ( & format ! ( "{}/perf/onpush" , site_url) ) . send ( ) ?;
858
+ client. post ( format ! ( "{}/perf/onpush" , site_url) ) . send ( ) ?;
857
859
858
860
res. fail_if_nonzero ( ) ?;
859
861
}
@@ -912,8 +914,8 @@ fn main_result() -> anyhow::Result<i32> {
912
914
let mut get_toolchain_and_profile =
913
915
|rustc : & str , suffix : & str | -> anyhow:: Result < String > {
914
916
let toolchain = get_local_toolchain (
915
- & profiles,
916
- & rustc,
917
+ profiles,
918
+ rustc,
917
919
opts. rustdoc . as_deref ( ) ,
918
920
local. cargo . as_deref ( ) ,
919
921
local. id . as_deref ( ) ,
@@ -926,8 +928,8 @@ fn main_result() -> anyhow::Result<i32> {
926
928
profiler,
927
929
& out_dir,
928
930
& benchmarks,
929
- & profiles,
930
- & scenarios,
931
+ profiles,
932
+ scenarios,
931
933
& mut errors,
932
934
) ;
933
935
Ok ( toolchain. id )
@@ -950,20 +952,23 @@ fn main_result() -> anyhow::Result<i32> {
950
952
& id2,
951
953
& out_dir,
952
954
& benchmarks,
953
- & profiles,
954
- & scenarios,
955
+ profiles,
956
+ scenarios,
955
957
& mut errors,
956
958
) ;
957
- if diffs. len ( ) > 1 {
958
- eprintln ! ( "Diffs:" ) ;
959
- for diff in diffs {
960
- eprintln ! ( "{}" , diff. to_string_lossy( ) ) ;
959
+ match diffs. len ( ) . cmp ( & 1 ) {
960
+ Ordering :: Equal => {
961
+ let short = out_dir. join ( "cgann-diff-latest" ) ;
962
+ std:: fs:: copy ( & diffs[ 0 ] , & short) . expect ( "copy to short path" ) ;
963
+ eprintln ! ( "Original diff at: {}" , diffs[ 0 ] . to_string_lossy( ) ) ;
964
+ eprintln ! ( "Short path: {}" , short. to_string_lossy( ) ) ;
965
+ }
966
+ _ => {
967
+ eprintln ! ( "Diffs:" ) ;
968
+ for diff in diffs {
969
+ eprintln ! ( "{}" , diff. to_string_lossy( ) ) ;
970
+ }
961
971
}
962
- } else if diffs. len ( ) == 1 {
963
- let short = out_dir. join ( "cgann-diff-latest" ) ;
964
- std:: fs:: copy ( & diffs[ 0 ] , & short) . expect ( "copy to short path" ) ;
965
- eprintln ! ( "Original diff at: {}" , diffs[ 0 ] . to_string_lossy( ) ) ;
966
- eprintln ! ( "Short path: {}" , short. to_string_lossy( ) ) ;
967
972
}
968
973
}
969
974
} else {
@@ -983,8 +988,8 @@ fn main_result() -> anyhow::Result<i32> {
983
988
. unwrap ( ) ;
984
989
let last_sha = String :: from_utf8 ( last_sha. stdout ) . expect ( "utf8" ) ;
985
990
let last_sha = last_sha. split_whitespace ( ) . next ( ) . expect ( & last_sha) ;
986
- let commit = get_commit_or_fake_it ( & last_sha) . expect ( "success" ) ;
987
- let mut sysroot = Sysroot :: install ( commit. sha . to_string ( ) , & target_triple) ?;
991
+ let commit = get_commit_or_fake_it ( last_sha) . expect ( "success" ) ;
992
+ let mut sysroot = Sysroot :: install ( commit. sha , & target_triple) ?;
988
993
sysroot. preserve ( ) ; // don't delete it
989
994
990
995
// Print the directory containing the toolchain.
@@ -1021,7 +1026,7 @@ async fn init_compile_collector(
1021
1026
) -> ( Box < dyn Connection > , CollectorCtx ) {
1022
1027
let mut conn = pool. connection ( ) . await ;
1023
1028
let collector = CollectorStepBuilder :: default ( )
1024
- . record_compile_benchmarks ( & benchmarks, bench_rustc)
1029
+ . record_compile_benchmarks ( benchmarks, bench_rustc)
1025
1030
. start_collection ( conn. as_mut ( ) , artifact_id)
1026
1031
. await ;
1027
1032
( conn, collector)
@@ -1035,7 +1040,7 @@ fn bench_published_artifact(
1035
1040
benchmark_dir : & Path ,
1036
1041
) -> anyhow:: Result < ( ) > {
1037
1042
let status = Command :: new ( "rustup" )
1038
- . args ( & [ "install" , "--profile=minimal" , & toolchain] )
1043
+ . args ( [ "install" , "--profile=minimal" , & toolchain] )
1039
1044
. status ( )
1040
1045
. context ( "rustup install" ) ?;
1041
1046
if !status. success ( ) {
@@ -1071,7 +1076,7 @@ fn bench_published_artifact(
1071
1076
let cargo = which ( "cargo" ) ?;
1072
1077
1073
1078
// Exclude benchmarks that don't work with a stable compiler.
1074
- let mut benchmarks = get_compile_benchmarks ( & benchmark_dir, None , None , None ) ?;
1079
+ let mut benchmarks = get_compile_benchmarks ( benchmark_dir, None , None , None ) ?;
1075
1080
benchmarks. retain ( |b| b. category ( ) . is_stable ( ) ) ;
1076
1081
1077
1082
let artifact_id = ArtifactId :: Tag ( toolchain) ;
@@ -1091,7 +1096,7 @@ fn bench_published_artifact(
1091
1096
rustdoc : Some ( Path :: new ( rustdoc. trim ( ) ) ) ,
1092
1097
cargo : Path :: new ( cargo. trim ( ) ) ,
1093
1098
is_nightly : false ,
1094
- triple : & target_triple,
1099
+ triple : target_triple,
1095
1100
} ,
1096
1101
& benchmarks,
1097
1102
Some ( 3 ) ,
@@ -1102,7 +1107,7 @@ fn bench_published_artifact(
1102
1107
Ok ( ( ) )
1103
1108
}
1104
1109
1105
- fn add_perf_config ( directory : & PathBuf , category : Category ) {
1110
+ fn add_perf_config ( directory : & Path , category : Category ) {
1106
1111
let data = serde_json:: json!( {
1107
1112
"category" : category. to_string( )
1108
1113
} ) ;
@@ -1118,10 +1123,12 @@ fn add_perf_config(directory: &PathBuf, category: Category) {
1118
1123
fn check_target_dir ( target_dir : & Path , force : bool ) -> anyhow:: Result < ( ) > {
1119
1124
if target_dir. exists ( ) {
1120
1125
if force {
1121
- std:: fs:: remove_dir_all ( & target_dir) . expect ( & format ! (
1122
- "Cannot remove previous directory at {}" ,
1123
- target_dir. display( )
1124
- ) ) ;
1126
+ std:: fs:: remove_dir_all ( target_dir) . unwrap_or_else ( |_| {
1127
+ panic ! (
1128
+ "Cannot remove previous directory at {}" ,
1129
+ target_dir. display( )
1130
+ )
1131
+ } ) ;
1125
1132
} else {
1126
1133
return Err ( anyhow:: anyhow!(
1127
1134
"Directory {} already exists" ,
@@ -1138,9 +1145,9 @@ fn get_downloaded_crate_target(benchmark_dir: &Path, cmd: &DownloadCommand) -> P
1138
1145
// URLs in general can end with /, which we also want to remove to make sure that the
1139
1146
// last part of the URL is the repository name.
1140
1147
DownloadSubcommand :: Git { url } => url
1141
- . trim_end_matches ( "/" )
1148
+ . trim_end_matches ( '/' )
1142
1149
. trim_end_matches ( ".git" )
1143
- . split ( "/" )
1150
+ . split ( '/' )
1144
1151
. last ( )
1145
1152
. expect ( "Crate name could not be determined from git URL" )
1146
1153
. to_string ( ) ,
@@ -1168,7 +1175,7 @@ fn download_from_git(target: &Path, url: &str) -> anyhow::Result<()> {
1168
1175
log:: error!( "Could not delete .git directory: {error:?}" ) ;
1169
1176
}
1170
1177
1171
- utils:: fs:: rename ( & tmpdir, & target) ?;
1178
+ utils:: fs:: rename ( & tmpdir, target) ?;
1172
1179
Ok ( ( ) )
1173
1180
}
1174
1181
@@ -1198,7 +1205,7 @@ fn download_from_crates_io(target_dir: &Path, krate: &str, version: &str) -> any
1198
1205
// under <crate-name>-<version> directory.
1199
1206
let unpacked_dir = tmpdir. path ( ) . join ( format ! ( "{krate}-{version}" ) ) ;
1200
1207
generate_lockfile ( & unpacked_dir) ;
1201
- utils:: fs:: rename ( & unpacked_dir, & target_dir) ?;
1208
+ utils:: fs:: rename ( & unpacked_dir, target_dir) ?;
1202
1209
1203
1210
Ok ( ( ) )
1204
1211
}
@@ -1235,7 +1242,7 @@ fn get_commit_or_fake_it(sha: &str) -> anyhow::Result<Commit> {
1235
1242
log:: warn!( "utilizing fake commit!" ) ;
1236
1243
Commit {
1237
1244
sha : sha. into ( ) ,
1238
- date : database:: Date :: ymd_hms ( 2000 , 01 , 01 , 0 , 0 , 0 ) ,
1245
+ date : database:: Date :: ymd_hms ( 2000 , 1 , 1 , 0 , 0 , 0 ) ,
1239
1246
r#type : CommitType :: Master ,
1240
1247
}
1241
1248
} ) )
0 commit comments