@@ -11,6 +11,7 @@ use std::collections::{BTreeSet, HashMap, HashSet};
11
11
use std:: env;
12
12
use std:: fs;
13
13
use std:: path:: { Path , PathBuf } ;
14
+ use std:: sync:: Arc ;
14
15
15
16
use anyhow:: Context ;
16
17
use chrono:: { Duration , Utc } ;
@@ -163,8 +164,8 @@ pub struct InputData {
163
164
pub last_date : Date ,
164
165
165
166
/// `data_real` is as-is, `data` has been interpolated.
166
- data_real : Vec < CommitData > ,
167
- data : Vec < CommitData > ,
167
+ data_real : Vec < Arc < CommitData > > ,
168
+ data : Vec < Arc < CommitData > > ,
168
169
169
170
/// The benchmarks we interpolated for a given commit.
170
171
///
@@ -181,7 +182,7 @@ pub struct InputData {
181
182
}
182
183
183
184
impl InputData {
184
- pub fn data ( & self , interpolate : Interpolate ) -> & [ CommitData ] {
185
+ pub fn data ( & self , interpolate : Interpolate ) -> & [ Arc < CommitData > ] {
185
186
match interpolate {
186
187
Interpolate :: Yes => & self . data ,
187
188
Interpolate :: No => & self . data_real ,
@@ -277,7 +278,7 @@ impl InputData {
277
278
}
278
279
279
280
if commits. insert ( contents. commit . clone ( ) ) {
280
- data. push ( contents) ;
281
+ data. push ( Arc :: new ( contents) ) ;
281
282
}
282
283
}
283
284
}
@@ -300,7 +301,7 @@ impl InputData {
300
301
}
301
302
302
303
pub fn new (
303
- data : Vec < CommitData > ,
304
+ data : Vec < Arc < CommitData > > ,
304
305
artifact_data : HashMap < String , ArtifactData > ,
305
306
config : Config ,
306
307
) -> anyhow:: Result < InputData > {
@@ -454,7 +455,7 @@ impl InputData {
454
455
455
456
let mut assoc = AssociatedData {
456
457
commit_idx,
457
- commit : & cd. commit ,
458
+ commit : cd. commit ,
458
459
data : & data_real,
459
460
commits : & data_commits,
460
461
commit_map : & commit_map,
@@ -466,26 +467,28 @@ impl InputData {
466
467
dur : & mut dur,
467
468
} ;
468
469
469
- let entry = cd
470
- . benchmarks
471
- . entry ( benchmark_name. to_owned ( ) )
472
- . or_insert_with ( || Err ( String :: from ( "dummy bench" ) ) ) ;
473
-
474
470
// benchmark did not run successfully at this commit
475
471
// or benchmark did not attempt to run at this commit
476
- if entry. is_err ( ) {
472
+ if cd
473
+ . benchmarks
474
+ . get ( benchmark_name. as_str ( ) )
475
+ . map_or ( true , |c| c. is_err ( ) )
476
+ {
477
477
let runs = fill_benchmark_data ( benchmark_name, & mut assoc) ;
478
478
// If we couldn't do this then do nothing
479
479
if let Some ( runs) = runs {
480
- * entry = Ok ( Benchmark {
481
- name : benchmark_name. to_owned ( ) ,
482
- runs : runs,
483
- } ) ;
480
+ Arc :: make_mut ( cd) . benchmarks . insert (
481
+ benchmark_name. to_owned ( ) ,
482
+ Ok ( Benchmark {
483
+ name : benchmark_name. to_owned ( ) ,
484
+ runs : runs,
485
+ } ) ,
486
+ ) ;
484
487
}
485
488
}
486
489
487
490
// benchmark exists, but might have runs missing
488
- if let Ok ( benchmark) = entry {
491
+ if let Some ( Ok ( benchmark) ) = cd . benchmarks . get ( benchmark_name . as_str ( ) ) {
489
492
// If we've not had a benchmark at all in the last few
490
493
// commits then just skip run interpolation for it; the
491
494
// benchmark should get total-benchmark interpolated.
@@ -496,6 +499,12 @@ impl InputData {
496
499
. collect :: < Vec < _ > > ( ) ;
497
500
if !missing_runs. is_empty ( ) {
498
501
let before = benchmark. runs . len ( ) ;
502
+ let benchmark = Arc :: make_mut ( cd)
503
+ . benchmarks
504
+ . get_mut ( benchmark_name. as_str ( ) )
505
+ . unwrap ( )
506
+ . as_mut ( )
507
+ . unwrap ( ) ;
499
508
fill_benchmark_runs ( benchmark, missing_runs, & mut assoc) ;
500
509
assert_ne ! ( before, benchmark. runs. len( ) , "made progress" ) ;
501
510
}
@@ -630,8 +639,8 @@ pub struct Percent(#[serde(with = "util::round_float")] pub f64);
630
639
631
640
struct AssociatedData < ' a > {
632
641
commit_idx : usize ,
633
- commit : & ' a Commit ,
634
- data : & ' a [ CommitData ] ,
642
+ commit : Commit ,
643
+ data : & ' a [ Arc < CommitData > ] ,
635
644
commits : & ' a [ Commit ] ,
636
645
commit_map : & ' a HashMap < Commit , usize > ,
637
646
interpolated : & ' a mut HashMap < Sha , Vec < Interpolation > > ,
@@ -666,8 +675,8 @@ fn fill_benchmark_runs(
666
675
let end_commit = end. map ( |( idx, _) | data. commits [ * idx] . clone ( ) ) ;
667
676
* data. dur += time_start. elapsed ( ) ;
668
677
669
- assert_ne ! ( start_commit. as_ref ( ) , Some ( data. commit) ) ;
670
- assert_ne ! ( end_commit. as_ref ( ) , Some ( data. commit) ) ;
678
+ assert_ne ! ( start_commit, Some ( data. commit) ) ;
679
+ assert_ne ! ( end_commit, Some ( data. commit) ) ;
671
680
672
681
let interpolations = data
673
682
. interpolated
0 commit comments