Skip to content

Commit 87d51ce

Browse files
authored
Merge pull request #1331 from rylev/change-matnitude-depending-on-metric
Change how we measure absolute magnitude to depend on the metric
2 parents 2484444 + a4e82fd commit 87d51ce

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

docs/comparison-analysis.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ The relevance test run summary is determined by the number of significant and re
5656

5757
#### Magnitude
5858

59-
Magnitude is a combination of two factors:
60-
* how large a change is regardless of the direction of the change
61-
* how much that change went over the significance threshold
59+
Magnitude is a small set of discrete buckets describing how "big" a change is from "very small" to "very large". It is a combination of two factors:
60+
* how much that change went over the significance threshold.
61+
* this criteria is the same regardless of which metric is being measured.
62+
* how large percentage wise a change is regardless of the direction of the change.
63+
* which bucket a change falls into is metric dependent (i.e., changes of the same percent might fall into different buckets depending on the metric in question)
6264

63-
As an example, if a change that is large in absolute terms only exceeds the significance threshold by a small factor, then the overall magnitude of the change is considered small.
65+
As an example, if a change that is large in absolute terms only exceeds the significance threshold by a small factor, then the overall magnitude of the change is considered small. On the other hand, if a change is small in absolute terms but exceeds the significance threshold by a very large amount, then the overall magnitude of the change is considered large.
6466

6567
#### Relevance algorithm
6668

site/src/comparison.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,31 @@ impl Metric {
210210
Self::CpuClock => "cpu-clock",
211211
}
212212
}
213+
214+
/// Determines the magnitude of a percent relative change for a given metric.
215+
///
216+
/// Takes into account how noisy the stat is. For example, instruction
217+
/// count which is normally not very noisy has smaller thresholds than
218+
/// max-rss which can be noisy.
219+
fn relative_change_magnitude(&self, change: f64) -> Magnitude {
220+
let noise_factor = if self.is_typically_noisy() { 2.0 } else { 1.0 };
221+
let change = change / noise_factor;
222+
if change < 0.2 {
223+
Magnitude::VerySmall
224+
} else if change < 1.0 {
225+
Magnitude::Small
226+
} else if change < 2.0 {
227+
Magnitude::Medium
228+
} else if change < 5.0 {
229+
Magnitude::Large
230+
} else {
231+
Magnitude::VeryLarge
232+
}
233+
}
234+
235+
fn is_typically_noisy(&self) -> bool {
236+
!matches!(self, Self::Instructions)
237+
}
213238
}
214239

215240
/// A summary of a given comparison
@@ -638,6 +663,7 @@ async fn compare_given_commits(
638663
benchmark: test_case.0,
639664
profile: test_case.1,
640665
scenario: test_case.2,
666+
metric,
641667
historical_data: historical_data.data.remove(&test_case),
642668
results: (a, b),
643669
})
@@ -1015,6 +1041,7 @@ pub struct TestResultComparison {
10151041
benchmark: Benchmark,
10161042
profile: Profile,
10171043
scenario: Scenario,
1044+
metric: Metric,
10181045
historical_data: Option<HistoricalData>,
10191046
results: (f64, f64),
10201047
}
@@ -1083,17 +1110,7 @@ impl TestResultComparison {
10831110
} else {
10841111
Magnitude::VeryLarge
10851112
};
1086-
let absolute_magnitude = if change < 0.002 {
1087-
Magnitude::VerySmall
1088-
} else if change < 0.01 {
1089-
Magnitude::Small
1090-
} else if change < 0.02 {
1091-
Magnitude::Medium
1092-
} else if change < 0.05 {
1093-
Magnitude::Large
1094-
} else {
1095-
Magnitude::VeryLarge
1096-
};
1113+
let absolute_magnitude = self.metric.relative_change_magnitude(change * 100.0);
10971114
fn as_u8(m: Magnitude) -> u8 {
10981115
match m {
10991116
Magnitude::VerySmall => 1,
@@ -1457,6 +1474,7 @@ mod tests {
14571474
benchmark: index.to_string().as_str().into(),
14581475
profile: Profile::Check,
14591476
scenario: Scenario::Empty,
1477+
metric: Metric::Instructions,
14601478
historical_data: None,
14611479
results: (before, after),
14621480
});

0 commit comments

Comments
 (0)