Skip to content

Commit f95c90b

Browse files
committed
Extract function for determining whether an artifact comparison deserves attention
1 parent 1ac2572 commit f95c90b

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ target
44
/cache/
55
/rust.git/
66
/rust/
7+
/results

site/src/comparison.rs

+22-9
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,7 @@ async fn populate_report(
158158
(None, None) => return,
159159
};
160160

161-
let include_in_triage = match (primary.largest_change(), secondary.largest_change()) {
162-
(Some(c), _) if c.magnitude() >= Magnitude::Medium => true,
163-
(_, Some(c)) if c.magnitude() >= Magnitude::Medium => true,
164-
_ => {
165-
let primary_n = primary.num_changes();
166-
let secondary_n = secondary.num_changes();
167-
(primary_n * 2 + secondary_n) >= 6
168-
}
169-
};
161+
let include_in_triage = deserves_attention(&primary, &secondary);
170162

171163
if include_in_triage {
172164
let entry = report.entry(direction).or_default();
@@ -358,6 +350,27 @@ impl ArtifactComparisonSummary {
358350
}
359351
}
360352

353+
/// Whether we are confident enough that an artifact comparison represents a real change and thus deserves to be looked at.
354+
///
355+
/// For example, this can be used to determine if artifact comparisons with regressions should be labeled with the
356+
/// `perf-regression` GitHub label or should be shown in the perf triage report.
357+
pub(crate) fn deserves_attention(
358+
primary: &ArtifactComparisonSummary,
359+
secondary: &ArtifactComparisonSummary,
360+
) -> bool {
361+
match (primary.largest_change(), secondary.largest_change()) {
362+
(Some(c), _) if c.magnitude() >= Magnitude::Medium => true,
363+
(_, Some(c)) if c.magnitude() >= Magnitude::Medium => true,
364+
_ => {
365+
// How we determine whether a group of small changes deserves attention is and always will be arbitrary,
366+
// but this feels good enough for now. We may choose in the future to become more sophisticated about it.
367+
let primary_n = primary.num_changes();
368+
let secondary_n = secondary.num_changes();
369+
(primary_n * 2 + secondary_n) >= 6
370+
}
371+
}
372+
}
373+
361374
async fn write_triage_summary(
362375
comparison: &ArtifactComparison,
363376
primary: &ArtifactComparisonSummary,

site/src/github.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::api::github::Issue;
2-
use crate::comparison::{write_summary_table, ArtifactComparisonSummary, Direction, Magnitude};
2+
use crate::comparison::{
3+
deserves_attention, write_summary_table, ArtifactComparisonSummary, Direction,
4+
};
35
use crate::load::{Config, SiteCtxt, TryCommit};
46

57
use anyhow::Context as _;
@@ -637,16 +639,7 @@ fn next_steps(
637639
direction: Option<Direction>,
638640
is_master_commit: bool,
639641
) -> String {
640-
// whether we are confident enough this is a real change and it deserves to be looked at
641-
let deserves_attention = match (primary.largest_change(), secondary.largest_change()) {
642-
(Some(c), _) if c.magnitude() >= Magnitude::Medium => true,
643-
(_, Some(c)) if c.magnitude() >= Magnitude::Medium => true,
644-
_ => {
645-
let primary_n = primary.num_changes();
646-
let secondary_n = secondary.num_changes();
647-
(primary_n * 2 + secondary_n) >= 6
648-
}
649-
};
642+
let deserves_attention = deserves_attention(&primary, &secondary);
650643
let label = match (deserves_attention, direction) {
651644
(true, Some(Direction::Regression | Direction::Mixed)) => "+perf-regression",
652645
_ => "-perf-regression",

0 commit comments

Comments
 (0)