@@ -28,7 +28,8 @@ use tokio::runtime::Runtime;
28
28
use collector:: compile:: execute:: bencher:: BenchProcessor ;
29
29
use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
30
30
use collector:: runtime:: {
31
- bench_runtime, runtime_benchmark_dir, BenchmarkFilter , CargoIsolationMode ,
31
+ bench_runtime, runtime_benchmark_dir, BenchmarkFilter , BenchmarkSuite , CargoIsolationMode ,
32
+ DEFAULT_RUNTIME_ITERATIONS ,
32
33
} ;
33
34
use collector:: toolchain:: {
34
35
create_toolchain_from_published_version, get_local_toolchain, Sysroot , Toolchain ,
@@ -62,6 +63,12 @@ impl BenchmarkErrors {
62
63
}
63
64
}
64
65
66
+ #[ derive( Debug ) ]
67
+ struct BenchmarkDirs < ' a > {
68
+ compile : & ' a Path ,
69
+ runtime : & ' a Path ,
70
+ }
71
+
65
72
#[ allow( clippy:: too_many_arguments) ]
66
73
fn bench (
67
74
rt : & mut Runtime ,
@@ -563,7 +570,7 @@ enum Commands {
563
570
local : LocalOptions ,
564
571
565
572
/// How many iterations of each benchmark should be executed.
566
- #[ arg( long, default_value = "5" ) ]
573
+ #[ arg( long, default_value_t = DEFAULT_RUNTIME_ITERATIONS ) ]
567
574
iterations : u32 ,
568
575
569
576
#[ command( flatten) ]
@@ -693,6 +700,11 @@ fn main_result() -> anyhow::Result<i32> {
693
700
let compile_benchmark_dir = compile_benchmark_dir ( ) ;
694
701
let runtime_benchmark_dir = runtime_benchmark_dir ( ) ;
695
702
703
+ let benchmark_dirs = BenchmarkDirs {
704
+ compile : & compile_benchmark_dir,
705
+ runtime : & runtime_benchmark_dir,
706
+ } ;
707
+
696
708
let mut builder = tokio:: runtime:: Builder :: new_multi_thread ( ) ;
697
709
// We want to minimize noise from the runtime
698
710
builder
@@ -727,7 +739,7 @@ fn main_result() -> anyhow::Result<i32> {
727
739
} else {
728
740
CargoIsolationMode :: Isolated
729
741
} ;
730
- let suite = runtime:: create_runtime_benchmark_suite (
742
+ let suite = runtime:: prepare_runtime_benchmark_suite (
731
743
& toolchain,
732
744
& runtime_benchmark_dir,
733
745
isolation_mode,
@@ -783,8 +795,9 @@ fn main_result() -> anyhow::Result<i32> {
783
795
benchmarks. retain ( |b| b. category ( ) . is_primary_or_secondary ( ) ) ;
784
796
785
797
let artifact_id = ArtifactId :: Tag ( toolchain. id . clone ( ) ) ;
786
- let ( mut conn, collector) = rt. block_on ( init_compile_collector (
787
- & pool,
798
+ let mut conn = rt. block_on ( pool. connection ( ) ) ;
799
+ let collector = rt. block_on ( init_compile_collector (
800
+ conn. as_mut ( ) ,
788
801
& benchmarks,
789
802
bench_rustc. bench_rustc ,
790
803
artifact_id,
@@ -830,7 +843,12 @@ fn main_result() -> anyhow::Result<i32> {
830
843
match next {
831
844
NextArtifact :: Release ( tag) => {
832
845
let toolchain = create_toolchain_from_published_version ( & tag, & target_triple) ?;
833
- bench_published_artifact ( & toolchain, pool, & mut rt, & compile_benchmark_dir) ?;
846
+ bench_published_artifact (
847
+ & toolchain,
848
+ rt. block_on ( pool. connection ( ) ) ,
849
+ & mut rt,
850
+ & benchmark_dirs,
851
+ ) ?;
834
852
835
853
client. post ( format ! ( "{}/perf/onpush" , site_url) ) . send ( ) ?;
836
854
}
@@ -853,8 +871,9 @@ fn main_result() -> anyhow::Result<i32> {
853
871
benchmarks. retain ( |b| b. category ( ) . is_primary_or_secondary ( ) ) ;
854
872
855
873
let artifact_id = ArtifactId :: Commit ( commit) ;
856
- let ( mut conn, collector) = rt. block_on ( init_compile_collector (
857
- & pool,
874
+ let mut conn = rt. block_on ( pool. connection ( ) ) ;
875
+ let collector = rt. block_on ( init_compile_collector (
876
+ conn. as_mut ( ) ,
858
877
& benchmarks,
859
878
bench_rustc. bench_rustc ,
860
879
artifact_id,
@@ -882,8 +901,9 @@ fn main_result() -> anyhow::Result<i32> {
882
901
883
902
Commands :: BenchPublished { toolchain, db } => {
884
903
let pool = database:: Pool :: open ( & db. db ) ;
904
+ let conn = rt. block_on ( pool. connection ( ) ) ;
885
905
let toolchain = create_toolchain_from_published_version ( & toolchain, & target_triple) ?;
886
- bench_published_artifact ( & toolchain, pool , & mut rt, & compile_benchmark_dir ) ?;
906
+ bench_published_artifact ( & toolchain, conn , & mut rt, & benchmark_dirs ) ?;
887
907
Ok ( 0 )
888
908
}
889
909
@@ -1030,25 +1050,35 @@ fn main_result() -> anyhow::Result<i32> {
1030
1050
}
1031
1051
1032
1052
async fn init_compile_collector (
1033
- pool : & database :: Pool ,
1053
+ connection : & mut dyn Connection ,
1034
1054
benchmarks : & [ Benchmark ] ,
1035
1055
bench_rustc : bool ,
1036
1056
artifact_id : ArtifactId ,
1037
- ) -> ( Box < dyn Connection > , CollectorCtx ) {
1038
- let mut conn = pool. connection ( ) . await ;
1039
- let collector = CollectorStepBuilder :: default ( )
1057
+ ) -> CollectorCtx {
1058
+ CollectorStepBuilder :: default ( )
1040
1059
. record_compile_benchmarks ( benchmarks, bench_rustc)
1041
- . start_collection ( conn. as_mut ( ) , artifact_id)
1042
- . await ;
1043
- ( conn, collector)
1060
+ . start_collection ( connection, artifact_id)
1061
+ . await
1062
+ }
1063
+
1064
+ async fn init_runtime_collector (
1065
+ connection : & mut dyn Connection ,
1066
+ suite : & BenchmarkSuite ,
1067
+ artifact_id : ArtifactId ,
1068
+ ) -> CollectorCtx {
1069
+ CollectorStepBuilder :: default ( )
1070
+ . record_runtime_benchmarks ( suite)
1071
+ . start_collection ( connection, artifact_id)
1072
+ . await
1044
1073
}
1045
1074
1046
1075
fn bench_published_artifact (
1047
1076
toolchain : & Toolchain ,
1048
- pool : Pool ,
1077
+ mut connection : Box < dyn Connection > ,
1049
1078
rt : & mut Runtime ,
1050
- benchmark_dir : & Path ,
1079
+ dirs : & BenchmarkDirs ,
1051
1080
) -> anyhow:: Result < ( ) > {
1081
+ // Compile benchmarks
1052
1082
let profiles = if collector:: version_supports_doc ( & toolchain. id ) {
1053
1083
Profile :: all ( )
1054
1084
} else {
@@ -1061,29 +1091,51 @@ fn bench_published_artifact(
1061
1091
} ;
1062
1092
1063
1093
// Exclude benchmarks that don't work with a stable compiler.
1064
- let mut benchmarks = get_compile_benchmarks ( benchmark_dir , None , None , None ) ?;
1065
- benchmarks . retain ( |b| b. category ( ) . is_stable ( ) ) ;
1094
+ let mut compile_benchmarks = get_compile_benchmarks ( dirs . compile , None , None , None ) ?;
1095
+ compile_benchmarks . retain ( |b| b. category ( ) . is_stable ( ) ) ;
1066
1096
1067
1097
let artifact_id = ArtifactId :: Tag ( toolchain. id . clone ( ) ) ;
1068
- let ( mut conn , collector) = rt. block_on ( init_compile_collector (
1069
- & pool ,
1070
- & benchmarks ,
1098
+ let collector = rt. block_on ( init_compile_collector (
1099
+ connection . as_mut ( ) ,
1100
+ & compile_benchmarks ,
1071
1101
/* bench_rustc */ false ,
1072
- artifact_id,
1102
+ artifact_id. clone ( ) ,
1073
1103
) ) ;
1074
1104
let res = bench (
1075
1105
rt,
1076
- conn . as_mut ( ) ,
1106
+ connection . as_mut ( ) ,
1077
1107
& profiles,
1078
1108
& scenarios,
1079
1109
toolchain,
1080
- & benchmarks ,
1110
+ & compile_benchmarks ,
1081
1111
Some ( 3 ) ,
1082
1112
/* is_self_profile */ false ,
1083
1113
collector,
1084
1114
) ;
1085
- res. fail_if_nonzero ( ) ?;
1086
- Ok ( ( ) )
1115
+ let compile_result = res. fail_if_nonzero ( ) . context ( "Compile benchmarks failed" ) ;
1116
+
1117
+ // Runtime benchmarks
1118
+ let runtime_suite = runtime:: prepare_runtime_benchmark_suite (
1119
+ toolchain,
1120
+ dirs. runtime ,
1121
+ CargoIsolationMode :: Isolated ,
1122
+ ) ?;
1123
+ let collector = rt. block_on ( init_runtime_collector (
1124
+ connection. as_mut ( ) ,
1125
+ & runtime_suite,
1126
+ artifact_id,
1127
+ ) ) ;
1128
+ let runtime_result = rt
1129
+ . block_on ( bench_runtime (
1130
+ connection,
1131
+ runtime_suite,
1132
+ collector,
1133
+ BenchmarkFilter :: keep_all ( ) ,
1134
+ DEFAULT_RUNTIME_ITERATIONS ,
1135
+ ) )
1136
+ . context ( "Runtime benchmarks failed" ) ;
1137
+
1138
+ compile_result. or ( runtime_result)
1087
1139
}
1088
1140
1089
1141
fn add_perf_config ( directory : & Path , category : Category ) {
0 commit comments