Skip to content

Commit e312fa0

Browse files
committed
Always show errors when present
Previously when there were no relevant changes to show, we didn't show benchmark errors. However, it always makes sense to show new benchmark errors. This change makes it so that new benchmark errors are always shown when present.
1 parent 55dbcb9 commit e312fa0

File tree

2 files changed

+28
-38
lines changed

2 files changed

+28
-38
lines changed

site/src/comparison.rs

+10-17
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ pub async fn handle_compare(
125125
})
126126
.collect();
127127

128-
let mut new_errors = comparison.new_errors.into_iter().collect::<Vec<_>>();
128+
let mut new_errors = comparison
129+
.newly_failed_benchmarks
130+
.into_iter()
131+
.collect::<Vec<_>>();
129132
new_errors.sort();
130133
Ok(api::comparison::Response {
131134
prev,
@@ -172,8 +175,6 @@ pub struct ComparisonSummary {
172175
num_improvements: usize,
173176
/// The cached number of comparisons that are regressions
174177
num_regressions: usize,
175-
/// Which benchmarks had errors
176-
errors_in: Vec<String>,
177178
}
178179

179180
impl ComparisonSummary {
@@ -207,13 +208,10 @@ impl ComparisonSummary {
207208
};
208209
comparisons.sort_by(cmp);
209210

210-
let errors_in = comparison.new_errors.keys().cloned().collect::<Vec<_>>();
211-
212211
Some(ComparisonSummary {
213212
comparisons,
214213
num_improvements,
215214
num_regressions,
216-
errors_in,
217215
})
218216
}
219217

@@ -222,7 +220,6 @@ impl ComparisonSummary {
222220
comparisons: vec![],
223221
num_improvements: 0,
224222
num_regressions: 0,
225-
errors_in: vec![],
226223
}
227224
}
228225

@@ -319,10 +316,6 @@ impl ComparisonSummary {
319316
self.comparisons.is_empty()
320317
}
321318

322-
pub fn errors_in(&self) -> &[String] {
323-
&self.errors_in
324-
}
325-
326319
fn arithmetic_mean<'a>(
327320
&'a self,
328321
changes: impl Iterator<Item = &'a TestResultComparison>,
@@ -607,7 +600,7 @@ async fn compare_given_commits(
607600
a: ArtifactDescription::for_artifact(&*conn, a.clone(), master_commits).await,
608601
b: ArtifactDescription::for_artifact(&*conn, b.clone(), master_commits).await,
609602
statistics,
610-
new_errors: errors_in_b.into_iter().collect(),
603+
newly_failed_benchmarks: errors_in_b.into_iter().collect(),
611604
}))
612605
}
613606

@@ -755,7 +748,7 @@ pub struct Comparison {
755748
/// Statistics based on test case
756749
pub statistics: HashSet<TestResultComparison>,
757750
/// A map from benchmark name to an error which occured when building `b` but not `a`.
758-
pub new_errors: HashMap<String, String>,
751+
pub newly_failed_benchmarks: HashMap<String, String>,
759752
}
760753

761754
impl Comparison {
@@ -798,21 +791,21 @@ impl Comparison {
798791
.partition(|s| category_map.get(&s.benchmark()) == Some(&Category::Primary));
799792

800793
let (primary_errors, secondary_errors) = self
801-
.new_errors
794+
.newly_failed_benchmarks
802795
.into_iter()
803796
.partition(|(b, _)| category_map.get(&b.as_str().into()) == Some(&Category::Primary));
804797

805798
let primary = Comparison {
806799
a: self.a.clone(),
807800
b: self.b.clone(),
808801
statistics: primary,
809-
new_errors: primary_errors,
802+
newly_failed_benchmarks: primary_errors,
810803
};
811804
let secondary = Comparison {
812805
a: self.a,
813806
b: self.b,
814807
statistics: secondary,
815-
new_errors: secondary_errors,
808+
newly_failed_benchmarks: secondary_errors,
816809
};
817810
(
818811
ComparisonSummary::summarize_comparison(&primary),
@@ -1516,7 +1509,7 @@ mod tests {
15161509
bootstrap_total: 0,
15171510
},
15181511
statistics,
1519-
new_errors: Default::default(),
1512+
newly_failed_benchmarks: Default::default(),
15201513
};
15211514
ComparisonSummary::summarize_comparison(&comparison)
15221515
.unwrap_or_else(|| ComparisonSummary::empty())

site/src/github.rs

+18-21
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,21 @@ async fn categorize_benchmark(
666666
_ => return (String::from("ERROR categorizing benchmark run!"), None),
667667
};
668668

669+
let errors = if !comparison.newly_failed_benchmarks.is_empty() {
670+
let benchmarks = comparison
671+
.newly_failed_benchmarks
672+
.iter()
673+
.map(|(benchmark, _)| format!("- {benchmark}"))
674+
.collect::<Vec<_>>()
675+
.join("\n");
676+
format!(
677+
"\n**Warning ⚠**: The following benchmark(s) failed to build:\n{}\n",
678+
benchmarks,
679+
)
680+
} else {
681+
String::new()
682+
};
683+
669684
let benchmark_map = ctxt.get_benchmark_category_map().await;
670685
let (primary, secondary) = comparison.summarize_by_category(benchmark_map);
671686

@@ -675,8 +690,8 @@ async fn categorize_benchmark(
675690
if primary.is_none() && secondary.is_none() {
676691
return (
677692
format!(
678-
"This benchmark run did not return any relevant results.\n\n{}",
679-
DISAGREEMENT
693+
"This benchmark run did not return any relevant results.\n\n{}{}",
694+
DISAGREEMENT, errors
680695
),
681696
None,
682697
);
@@ -701,27 +716,9 @@ async fn categorize_benchmark(
701716
secondary.unwrap_or_else(|| ComparisonSummary::empty()),
702717
);
703718
write_summary_table(&primary, &secondary, true, &mut result);
704-
705-
if !primary.errors_in().is_empty() || !secondary.errors_in().is_empty() {
706-
let list_errored_benchmarks = |summary: ComparisonSummary| {
707-
summary
708-
.errors_in()
709-
.iter()
710-
.map(|benchmark| format!("- {benchmark}"))
711-
.collect::<Vec<_>>()
712-
.join("\n")
713-
};
714-
write!(
715-
result,
716-
"\nThe following benchmark(s) failed to build:\n{}{}\n",
717-
list_errored_benchmarks(primary),
718-
list_errored_benchmarks(secondary)
719-
)
720-
.unwrap();
721-
}
722719
}
723720

724-
write!(result, "\n{}", DISAGREEMENT).unwrap();
721+
write!(result, "\n{} {}", DISAGREEMENT, errors).unwrap();
725722

726723
let direction = primary_direction.or(secondary_direction);
727724
(result, direction)

0 commit comments

Comments
 (0)