@@ -11,6 +11,7 @@ use std::collections::{BTreeSet, HashMap, HashSet};
1111use std:: env;
1212use std:: fs;
1313use std:: path:: { Path , PathBuf } ;
14+ use std:: sync:: Arc ;
1415
1516use anyhow:: Context ;
1617use chrono:: { Duration , Utc } ;
@@ -163,8 +164,8 @@ pub struct InputData {
163164 pub last_date : Date ,
164165
165166 /// `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 > > ,
168169
169170 /// The benchmarks we interpolated for a given commit.
170171 ///
@@ -181,7 +182,7 @@ pub struct InputData {
181182}
182183
183184impl InputData {
184- pub fn data ( & self , interpolate : Interpolate ) -> & [ CommitData ] {
185+ pub fn data ( & self , interpolate : Interpolate ) -> & [ Arc < CommitData > ] {
185186 match interpolate {
186187 Interpolate :: Yes => & self . data ,
187188 Interpolate :: No => & self . data_real ,
@@ -277,7 +278,7 @@ impl InputData {
277278 }
278279
279280 if commits. insert ( contents. commit . clone ( ) ) {
280- data. push ( contents) ;
281+ data. push ( Arc :: new ( contents) ) ;
281282 }
282283 }
283284 }
@@ -300,7 +301,7 @@ impl InputData {
300301 }
301302
302303 pub fn new (
303- data : Vec < CommitData > ,
304+ data : Vec < Arc < CommitData > > ,
304305 artifact_data : HashMap < String , ArtifactData > ,
305306 config : Config ,
306307 ) -> anyhow:: Result < InputData > {
@@ -454,7 +455,7 @@ impl InputData {
454455
455456 let mut assoc = AssociatedData {
456457 commit_idx,
457- commit : & cd. commit ,
458+ commit : cd. commit ,
458459 data : & data_real,
459460 commits : & data_commits,
460461 commit_map : & commit_map,
@@ -466,26 +467,28 @@ impl InputData {
466467 dur : & mut dur,
467468 } ;
468469
469- let entry = cd
470- . benchmarks
471- . entry ( benchmark_name. to_owned ( ) )
472- . or_insert_with ( || Err ( String :: from ( "dummy bench" ) ) ) ;
473-
474470 // benchmark did not run successfully at this commit
475471 // 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+ {
477477 let runs = fill_benchmark_data ( benchmark_name, & mut assoc) ;
478478 // If we couldn't do this then do nothing
479479 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+ ) ;
484487 }
485488 }
486489
487490 // 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 ( ) ) {
489492 // If we've not had a benchmark at all in the last few
490493 // commits then just skip run interpolation for it; the
491494 // benchmark should get total-benchmark interpolated.
@@ -496,6 +499,12 @@ impl InputData {
496499 . collect :: < Vec < _ > > ( ) ;
497500 if !missing_runs. is_empty ( ) {
498501 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 ( ) ;
499508 fill_benchmark_runs ( benchmark, missing_runs, & mut assoc) ;
500509 assert_ne ! ( before, benchmark. runs. len( ) , "made progress" ) ;
501510 }
@@ -630,8 +639,8 @@ pub struct Percent(#[serde(with = "util::round_float")] pub f64);
630639
631640struct AssociatedData < ' a > {
632641 commit_idx : usize ,
633- commit : & ' a Commit ,
634- data : & ' a [ CommitData ] ,
642+ commit : Commit ,
643+ data : & ' a [ Arc < CommitData > ] ,
635644 commits : & ' a [ Commit ] ,
636645 commit_map : & ' a HashMap < Commit , usize > ,
637646 interpolated : & ' a mut HashMap < Sha , Vec < Interpolation > > ,
@@ -666,8 +675,8 @@ fn fill_benchmark_runs(
666675 let end_commit = end. map ( |( idx, _) | data. commits [ * idx] . clone ( ) ) ;
667676 * data. dur += time_start. elapsed ( ) ;
668677
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) ) ;
671680
672681 let interpolations = data
673682 . interpolated
0 commit comments