@@ -606,7 +606,8 @@ async fn compare_given_commits(
606
606
let statistics_for_a = statistics_from_series ( & mut responses) ;
607
607
let statistics_for_b = statistics_from_series ( & mut responses) ;
608
608
609
- let variances = BenchmarkVariances :: calculate ( ctxt, a. clone ( ) , master_commits, stat) . await ?;
609
+ let mut historical_data =
610
+ HistoricalDataMap :: calculate ( ctxt, a. clone ( ) , master_commits, stat) . await ?;
610
611
let statistics = statistics_for_a
611
612
. into_iter ( )
612
613
. filter_map ( |( test_case, a) | {
@@ -616,7 +617,7 @@ async fn compare_given_commits(
616
617
benchmark : test_case. 0 ,
617
618
profile : test_case. 1 ,
618
619
scenario : test_case. 2 ,
619
- variance : variances . data . get ( & test_case) . cloned ( ) ,
620
+ historical_data : historical_data . data . remove ( & test_case) ,
620
621
results : ( a, b) ,
621
622
} )
622
623
} )
@@ -815,14 +816,13 @@ impl Comparison {
815
816
}
816
817
}
817
818
818
- /// A description of the amount of variance a certain benchmark is historically
819
- /// experiencing at a given point in time.
820
- pub struct BenchmarkVariances {
821
- /// Variance data on a per test case basis
822
- pub data : HashMap < ( Benchmark , Profile , Scenario ) , BenchmarkVariance > ,
819
+ /// The historical data for a certain benchmark
820
+ pub struct HistoricalDataMap {
821
+ /// Historical data on a per test case basis
822
+ pub data : HashMap < ( Benchmark , Profile , Scenario ) , HistoricalData > ,
823
823
}
824
824
825
- impl BenchmarkVariances {
825
+ impl HistoricalDataMap {
826
826
const NUM_PREVIOUS_COMMITS : usize = 100 ;
827
827
const MIN_PREVIOUS_COMMITS : usize = 50 ;
828
828
@@ -832,18 +832,18 @@ impl BenchmarkVariances {
832
832
master_commits : & [ collector:: MasterCommit ] ,
833
833
stat : String ,
834
834
) -> Result < Self , BoxedError > {
835
- let mut variance_data = HashMap :: new ( ) ;
835
+ let mut historical_data = HashMap :: new ( ) ;
836
836
837
837
let previous_commits = Arc :: new ( previous_commits (
838
838
from,
839
839
Self :: NUM_PREVIOUS_COMMITS ,
840
840
master_commits,
841
841
) ) ;
842
842
843
- // Return early if we don't have enough data to calculate variance.
843
+ // Return early if we don't have enough data for historical analysis
844
844
if previous_commits. len ( ) < Self :: MIN_PREVIOUS_COMMITS {
845
845
return Ok ( Self {
846
- data : variance_data ,
846
+ data : historical_data ,
847
847
} ) ;
848
848
}
849
849
@@ -860,37 +860,25 @@ impl BenchmarkVariances {
860
860
861
861
for _ in previous_commits. iter ( ) {
862
862
for ( test_case, stat) in statistics_from_series ( & mut previous_commit_series) {
863
- variance_data . entry ( test_case) . or_default ( ) . push ( stat) ;
863
+ historical_data . entry ( test_case) . or_default ( ) . push ( stat) ;
864
864
}
865
865
}
866
866
867
867
// Only retain test cases for which we have enough data to calculate variance.
868
- variance_data. retain ( |_, v| v. data . len ( ) >= Self :: MIN_PREVIOUS_COMMITS ) ;
869
-
870
- for ( ( bench, _, _) , results) in variance_data. iter_mut ( ) {
871
- log:: trace!( "Calculating variance for: {}" , bench) ;
872
- results. calculate_description ( ) ;
873
- }
868
+ historical_data. retain ( |_, v| v. data . len ( ) >= Self :: MIN_PREVIOUS_COMMITS ) ;
874
869
875
870
Ok ( Self {
876
- data : variance_data ,
871
+ data : historical_data ,
877
872
} )
878
873
}
879
874
}
880
875
881
876
#[ derive( Debug , Default , Clone , Serialize ) ]
882
- pub struct BenchmarkVariance {
877
+ pub struct HistoricalData {
883
878
data : Vec < f64 > ,
884
- description : BenchmarkVarianceDescription ,
885
879
}
886
880
887
- impl BenchmarkVariance {
888
- /// The ratio of change that we consider significant.
889
- const SIGNFICANT_DELTA_THRESHOLD : f64 = 0.01 ;
890
- /// The percentage of significant changes that we consider too high
891
- const SIGNFICANT_CHANGE_THRESHOLD : f64 = 5.0 ;
892
- /// The ratio of change that constitutes noisy data
893
- const NOISE_THRESHOLD : f64 = 0.001 ;
881
+ impl HistoricalData {
894
882
/// The multiple of the IQR above Q3 that signifies significance
895
883
const IQR_MULTIPLIER : f64 = 3.0 ;
896
884
@@ -954,36 +942,6 @@ impl BenchmarkVariance {
954
942
( q1, q3)
955
943
}
956
944
957
- fn calculate_description ( & mut self ) {
958
- self . description = BenchmarkVarianceDescription :: Normal ;
959
-
960
- let percent_changes = self . percent_changes ( ) ;
961
- let non_significant = percent_changes
962
- . iter ( )
963
- . take_while ( |& & c| c < Self :: SIGNFICANT_DELTA_THRESHOLD )
964
- . collect :: < Vec < _ > > ( ) ;
965
-
966
- let percent_significant_changes = ( ( percent_changes. len ( ) - non_significant. len ( ) ) as f64
967
- / percent_changes. len ( ) as f64 )
968
- * 100.0 ;
969
- log:: trace!(
970
- "Percent significant changes: {:.1}%" ,
971
- percent_significant_changes
972
- ) ;
973
-
974
- if percent_significant_changes > Self :: SIGNFICANT_CHANGE_THRESHOLD {
975
- self . description = BenchmarkVarianceDescription :: HighlyVariable ;
976
- return ;
977
- }
978
-
979
- let delta_mean =
980
- non_significant. iter ( ) . cloned ( ) . sum :: < f64 > ( ) / ( non_significant. len ( ) as f64 ) ;
981
- log:: trace!( "Ratio change: {:.4}" , delta_mean) ;
982
- if delta_mean > Self :: NOISE_THRESHOLD {
983
- self . description = BenchmarkVarianceDescription :: Noisy ;
984
- }
985
- }
986
-
987
945
// Absolute deltas between adjacent results
988
946
fn deltas ( & self ) -> impl Iterator < Item = f64 > + ' _ {
989
947
self . data
@@ -999,24 +957,6 @@ impl BenchmarkVariance {
999
957
}
1000
958
}
1001
959
1002
- #[ derive( Debug , Clone , Copy , Serialize ) ]
1003
- #[ serde( tag = "type" , content = "percent" ) ]
1004
- pub enum BenchmarkVarianceDescription {
1005
- Normal ,
1006
- /// A highly variable benchmark that produces many significant changes.
1007
- /// This might indicate a benchmark which is very sensitive to compiler changes.
1008
- HighlyVariable ,
1009
- /// A noisy benchmark which is likely to see changes in performance simply between
1010
- /// compiler runs.
1011
- Noisy ,
1012
- }
1013
-
1014
- impl Default for BenchmarkVarianceDescription {
1015
- fn default ( ) -> Self {
1016
- Self :: Normal
1017
- }
1018
- }
1019
-
1020
960
/// Gets the previous commit
1021
961
pub fn prev_commit < ' a > (
1022
962
artifact : & ArtifactId ,
@@ -1048,14 +988,14 @@ pub struct TestResultComparison {
1048
988
benchmark : Benchmark ,
1049
989
profile : Profile ,
1050
990
scenario : Scenario ,
1051
- variance : Option < BenchmarkVariance > ,
991
+ historical_data : Option < HistoricalData > ,
1052
992
results : ( f64 , f64 ) ,
1053
993
}
1054
994
1055
995
impl TestResultComparison {
1056
996
/// The amount of relative change considered significant when
1057
997
/// we cannot determine from historical data
1058
- const SIGNIFICANT_RELATIVE_CHANGE_THRESHOLD : f64 = 0.002 ;
998
+ const DEFAULT_SIGNIFICANCE_THRESHOLD : f64 = 0.002 ;
1059
999
1060
1000
pub fn benchmark ( & self ) -> Benchmark {
1061
1001
self . benchmark
@@ -1077,10 +1017,10 @@ impl TestResultComparison {
1077
1017
1078
1018
/// Magnitude of change considered significant
1079
1019
fn significance_threshold ( & self ) -> f64 {
1080
- self . variance
1020
+ self . historical_data
1081
1021
. as_ref ( )
1082
- . map ( |v| v . significance_threshold ( ) )
1083
- . unwrap_or ( Self :: SIGNIFICANT_RELATIVE_CHANGE_THRESHOLD )
1022
+ . map ( |d| d . significance_threshold ( ) )
1023
+ . unwrap_or ( Self :: DEFAULT_SIGNIFICANCE_THRESHOLD )
1084
1024
}
1085
1025
1086
1026
/// This is a numeric magnitude of a particular change.
@@ -1139,7 +1079,7 @@ impl TestResultComparison {
1139
1079
}
1140
1080
1141
1081
fn is_dodgy ( & self ) -> bool {
1142
- self . variance
1082
+ self . historical_data
1143
1083
. as_ref ( )
1144
1084
. map ( |v| v. is_dodgy ( ) )
1145
1085
. unwrap_or ( false )
@@ -1473,7 +1413,7 @@ mod tests {
1473
1413
benchmark : index. to_string ( ) . as_str ( ) . into ( ) ,
1474
1414
profile : Profile :: Check ,
1475
1415
scenario : Scenario :: Empty ,
1476
- variance : None ,
1416
+ historical_data : None ,
1477
1417
results : ( before, after) ,
1478
1418
} ) ;
1479
1419
}
0 commit comments