Skip to content

Commit bf4aacc

Browse files
authored
Merge pull request #1276 from rylev/always-show-new-errors
Always show errors when present
2 parents 2b236f5 + e08d1fb commit bf4aacc

File tree

2 files changed

+25
-40
lines changed

2 files changed

+25
-40
lines changed

site/src/comparison.rs

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

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

178179
impl ComparisonSummary {
@@ -206,13 +207,10 @@ impl ComparisonSummary {
206207
};
207208
comparisons.sort_by(cmp);
208209

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

@@ -221,7 +219,6 @@ impl ComparisonSummary {
221219
comparisons: vec![],
222220
num_improvements: 0,
223221
num_regressions: 0,
224-
errors_in: vec![],
225222
}
226223
}
227224

@@ -318,10 +315,6 @@ impl ComparisonSummary {
318315
self.comparisons.is_empty()
319316
}
320317

321-
pub fn errors_in(&self) -> &[String] {
322-
&self.errors_in
323-
}
324-
325318
fn arithmetic_mean<'a>(
326319
&'a self,
327320
changes: impl Iterator<Item = &'a TestResultComparison>,
@@ -606,7 +599,7 @@ async fn compare_given_commits(
606599
a: ArtifactDescription::for_artifact(&*conn, a.clone(), master_commits).await,
607600
b: ArtifactDescription::for_artifact(&*conn, b.clone(), master_commits).await,
608601
statistics,
609-
new_errors: errors_in_b.into_iter().collect(),
602+
newly_failed_benchmarks: errors_in_b.into_iter().collect(),
610603
}))
611604
}
612605

@@ -754,7 +747,7 @@ pub struct Comparison {
754747
/// Statistics based on test case
755748
pub statistics: HashSet<TestResultComparison>,
756749
/// A map from benchmark name to an error which occured when building `b` but not `a`.
757-
pub new_errors: HashMap<String, String>,
750+
pub newly_failed_benchmarks: HashMap<String, String>,
758751
}
759752

760753
impl Comparison {
@@ -797,21 +790,21 @@ impl Comparison {
797790
.partition(|s| category_map.get(&s.benchmark()) == Some(&Category::Primary));
798791

799792
let (primary_errors, secondary_errors) = self
800-
.new_errors
793+
.newly_failed_benchmarks
801794
.into_iter()
802795
.partition(|(b, _)| category_map.get(&b.as_str().into()) == Some(&Category::Primary));
803796

804797
let primary = Comparison {
805798
a: self.a.clone(),
806799
b: self.b.clone(),
807800
statistics: primary,
808-
new_errors: primary_errors,
801+
newly_failed_benchmarks: primary_errors,
809802
};
810803
let secondary = Comparison {
811804
a: self.a,
812805
b: self.b,
813806
statistics: secondary,
814-
new_errors: secondary_errors,
807+
newly_failed_benchmarks: secondary_errors,
815808
};
816809
(
817810
ComparisonSummary::summarize_comparison(&primary),
@@ -1501,7 +1494,7 @@ mod tests {
15011494
bootstrap_total: 0,
15021495
},
15031496
statistics,
1504-
new_errors: Default::default(),
1497+
newly_failed_benchmarks: Default::default(),
15051498
};
15061499
ComparisonSummary::summarize_comparison(&comparison)
15071500
.unwrap_or_else(|| ComparisonSummary::empty())

site/src/github.rs

+15-23
Original file line numberDiff line numberDiff line change
@@ -666,18 +666,28 @@ 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!("\n**Warning ⚠**: The following benchmark(s) failed to build:\n{benchmarks}\n")
677+
} else {
678+
String::new()
679+
};
680+
669681
let benchmark_map = ctxt.get_benchmark_category_map().await;
670682
let (primary, secondary) = comparison.summarize_by_category(benchmark_map);
671683

672684
const DISAGREEMENT: &str = "If you disagree with this performance assessment, \
673685
please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
686+
let footer = format!("{DISAGREEMENT}{errors}");
674687

675688
if primary.is_none() && secondary.is_none() {
676689
return (
677-
format!(
678-
"This benchmark run did not return any relevant results.\n\n{}",
679-
DISAGREEMENT
680-
),
690+
format!("This benchmark run did not return any relevant results.\n\n{footer}"),
681691
None,
682692
);
683693
}
@@ -701,27 +711,9 @@ async fn categorize_benchmark(
701711
secondary.unwrap_or_else(|| ComparisonSummary::empty()),
702712
);
703713
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-
}
722714
}
723715

724-
write!(result, "\n{}", DISAGREEMENT).unwrap();
716+
write!(result, "\n{footer}").unwrap();
725717

726718
let direction = primary_direction.or(secondary_direction);
727719
(result, direction)

0 commit comments

Comments
 (0)