4
4
extern crate clap;
5
5
6
6
use anyhow:: { bail, Context } ;
7
- use database:: { pool :: Connection , ArtifactId , Commit } ;
7
+ use database:: { ArtifactId , Commit } ;
8
8
use log:: debug;
9
9
use std:: collections:: HashSet ;
10
10
use std:: fs;
@@ -185,7 +185,7 @@ impl BenchmarkErrors {
185
185
186
186
fn bench (
187
187
rt : & mut Runtime ,
188
- mut conn : Box < dyn Connection > ,
188
+ pool : database :: Pool ,
189
189
cid : & ArtifactId ,
190
190
build_kinds : & [ BuildKind ] ,
191
191
run_kinds : & [ RunKind ] ,
@@ -194,6 +194,15 @@ fn bench(
194
194
iterations : usize ,
195
195
self_profile : bool ,
196
196
) -> BenchmarkErrors {
197
+ let mut conn = rt. block_on ( pool. connection ( ) ) ;
198
+ let status_conn;
199
+ let status_conn: Option < & dyn database:: Connection > =
200
+ if conn. separate_transaction_for_collector ( ) {
201
+ status_conn = rt. block_on ( pool. connection ( ) ) ;
202
+ Some ( & * status_conn)
203
+ } else {
204
+ None
205
+ } ;
197
206
let mut errors = BenchmarkErrors :: new ( ) ;
198
207
eprintln ! ( "Benchmarking {} for triple {}" , cid, compiler. triple) ;
199
208
@@ -223,7 +232,21 @@ fn bench(
223
232
let interned_cid = rt. block_on ( tx. conn ( ) . artifact_id ( & cid) ) ;
224
233
225
234
let start = Instant :: now ( ) ;
235
+ let steps = benchmarks
236
+ . iter ( )
237
+ . map ( |b| b. name . to_string ( ) )
238
+ . collect :: < Vec < _ > > ( ) ;
239
+ rt. block_on (
240
+ status_conn
241
+ . unwrap_or_else ( || & * tx. conn ( ) )
242
+ . collector_start ( interned_cid, & steps) ,
243
+ ) ;
226
244
for ( nth_benchmark, benchmark) in benchmarks. iter ( ) . enumerate ( ) {
245
+ rt. block_on (
246
+ status_conn
247
+ . unwrap_or_else ( || & * tx. conn ( ) )
248
+ . collector_start_step ( interned_cid, & benchmark. name . to_string ( ) ) ,
249
+ ) ;
227
250
rt. block_on (
228
251
tx. conn ( )
229
252
. record_benchmark ( benchmark. name . 0 . as_str ( ) , benchmark. supports_stable ( ) ) ,
@@ -254,6 +277,11 @@ fn bench(
254
277
& format ! ( "{:?}" , s) ,
255
278
) ) ;
256
279
} ;
280
+ rt. block_on (
281
+ status_conn
282
+ . unwrap_or_else ( || & * tx. conn ( ) )
283
+ . collector_end_step ( interned_cid, & benchmark. name . to_string ( ) ) ,
284
+ ) ;
257
285
}
258
286
let end = start. elapsed ( ) ;
259
287
@@ -516,15 +544,14 @@ fn main_result() -> anyhow::Result<i32> {
516
544
let self_profile = sub_m. is_present ( "SELF_PROFILE" ) ;
517
545
518
546
let pool = database:: Pool :: open ( db) ;
519
- let conn = rt. block_on ( pool. connection ( ) ) ;
520
547
521
548
let ( rustc, rustdoc, cargo) = get_local_toolchain ( & build_kinds, rustc, rustdoc, cargo) ?;
522
549
523
550
let benchmarks = get_benchmarks ( & benchmark_dir, include, exclude) ?;
524
551
525
552
let res = bench (
526
553
& mut rt,
527
- conn ,
554
+ pool ,
528
555
& ArtifactId :: Artifact ( id. to_string ( ) ) ,
529
556
& build_kinds,
530
557
& run_kinds,
@@ -567,7 +594,6 @@ fn main_result() -> anyhow::Result<i32> {
567
594
let commit = get_commit_or_fake_it ( & commit) ?;
568
595
569
596
let pool = database:: Pool :: open ( db) ;
570
- let conn = rt. block_on ( pool. connection ( ) ) ;
571
597
572
598
let sysroot = Sysroot :: install ( commit. sha . to_string ( ) , "x86_64-unknown-linux-gnu" )
573
599
. with_context ( || format ! ( "failed to install sysroot for {:?}" , commit) ) ?;
@@ -576,7 +602,7 @@ fn main_result() -> anyhow::Result<i32> {
576
602
577
603
let res = bench (
578
604
& mut rt,
579
- conn ,
605
+ pool ,
580
606
& ArtifactId :: Commit ( commit) ,
581
607
& BuildKind :: all ( ) ,
582
608
& RunKind :: all ( ) ,
@@ -608,7 +634,6 @@ fn main_result() -> anyhow::Result<i32> {
608
634
}
609
635
610
636
let pool = database:: Pool :: open ( db) ;
611
- let conn = rt. block_on ( pool. connection ( ) ) ;
612
637
613
638
let run_kinds = if collector:: version_supports_incremental ( toolchain) {
614
639
RunKind :: all ( )
@@ -647,7 +672,7 @@ fn main_result() -> anyhow::Result<i32> {
647
672
648
673
let res = bench (
649
674
& mut rt,
650
- conn ,
675
+ pool ,
651
676
& ArtifactId :: Artifact ( toolchain. to_string ( ) ) ,
652
677
& build_kinds,
653
678
& run_kinds,
0 commit comments