@@ -17,11 +17,13 @@ use std::cmp::Ordering;
17
17
use std:: ffi:: OsStr ;
18
18
use std:: fs;
19
19
use std:: fs:: File ;
20
+ use std:: future:: Future ;
20
21
use std:: io:: BufWriter ;
21
22
use std:: io:: Write ;
22
23
use std:: path:: { Path , PathBuf } ;
23
24
use std:: process;
24
25
use std:: process:: { Command , Stdio } ;
26
+ use std:: time:: Duration ;
25
27
use std:: { str, time:: Instant } ;
26
28
use tokio:: runtime:: Runtime ;
27
29
@@ -618,6 +620,7 @@ fn main_result() -> anyhow::Result<i32> {
618
620
builder
619
621
. worker_threads ( 1 )
620
622
. max_blocking_threads ( 1 )
623
+ . enable_time ( )
621
624
. enable_io ( ) ;
622
625
let mut rt = builder. build ( ) . expect ( "built runtime" ) ;
623
626
@@ -1084,6 +1087,18 @@ fn bench_published_artifact(
1084
1087
)
1085
1088
}
1086
1089
1090
+ const COMPILE_BENCHMARK_TIMEOUT : Duration = Duration :: from_secs ( 60 * 30 ) ;
1091
+
1092
+ async fn with_timeout < F : Future < Output = anyhow:: Result < ( ) > > > ( fut : F ) -> anyhow:: Result < ( ) > {
1093
+ match tokio:: time:: timeout ( COMPILE_BENCHMARK_TIMEOUT , fut) . await {
1094
+ Ok ( res) => res,
1095
+ Err ( _) => Err ( anyhow:: anyhow!(
1096
+ "Benchmark timeouted in {} seconds" ,
1097
+ COMPILE_BENCHMARK_TIMEOUT . as_secs( )
1098
+ ) ) ,
1099
+ }
1100
+ }
1101
+
1087
1102
/// Perform compile benchmarks.
1088
1103
fn bench_compile (
1089
1104
rt : & mut Runtime ,
@@ -1163,13 +1178,13 @@ fn bench_compile(
1163
1178
)
1164
1179
} ,
1165
1180
& |processor| {
1166
- rt. block_on ( benchmark. measure (
1181
+ rt. block_on ( with_timeout ( benchmark. measure (
1167
1182
processor,
1168
1183
& config. profiles ,
1169
1184
& config. scenarios ,
1170
1185
& shared. toolchain ,
1171
1186
config. iterations ,
1172
- ) )
1187
+ ) ) )
1173
1188
} ,
1174
1189
)
1175
1190
}
@@ -1181,7 +1196,7 @@ fn bench_compile(
1181
1196
Category :: Primary ,
1182
1197
& || eprintln ! ( "Special benchmark commencing (due to `--bench-rustc`)" ) ,
1183
1198
& |processor| {
1184
- rt. block_on ( processor. measure_rustc ( & shared. toolchain ) )
1199
+ rt. block_on ( with_timeout ( processor. measure_rustc ( & shared. toolchain ) ) )
1185
1200
. context ( "measure rustc" )
1186
1201
} ,
1187
1202
) ;
0 commit comments