Skip to content

Commit 795d7d5

Browse files
committed
Change GitHub comment output depending on perf categorization
1 parent 1bf6662 commit 795d7d5

File tree

1 file changed

+40
-29
lines changed

1 file changed

+40
-29
lines changed

site/src/github.rs

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::api::{github, ServerResult};
2+
use crate::comparison::{ComparisonSummary, Direction};
23
use crate::load::{Config, InputData, TryCommit};
34
use anyhow::Context as _;
45
use hashbrown::HashSet;
@@ -631,7 +632,23 @@ pub async fn post_finished(data: &InputData) {
631632
"https://perf.rust-lang.org/compare.html?start={}&end={}",
632633
commit.parent_sha, commit.sha
633634
);
634-
let summary = categorize_benchmark(&commit, data).await;
635+
let (summary, direction) = categorize_benchmark(&commit, data).await;
636+
let label = match direction {
637+
Some(Direction::Regression | Direction::Mixed) => "+perf-regression",
638+
Some(Direction::Improvement) | None => "-perf-regression",
639+
};
640+
641+
let rollup = if let Some(_) = direction {
642+
"Benchmarking this pull request showed some changes in performance \
643+
so we're automatically marking it as not fit for rolling up.
644+
645+
@bors rollup=never"
646+
} else {
647+
"Even though no performance changes were detected, if you still believe\
648+
this pull request to potentially be performance sensitive, consider running\
649+
`@bors rollup=never` or `@bors rollup=iffy`.\n"
650+
};
651+
635652
post_comment(
636653
&data.config,
637654
commit.pr,
@@ -640,27 +657,20 @@ pub async fn post_finished(data: &InputData) {
640657
641658
**Summary**: {}
642659
643-
Benchmarking this pull request likely means that it is \
644-
perf-sensitive, so we're automatically marking it as not fit \
645-
for rolling up. Please note that if the perf results are \
646-
neutral, you should likely undo the rollup=never given below \
647-
by specifying `rollup-` to bors.
648-
649-
Importantly, though, if the results of this run are \
650-
non-neutral **do not** roll this PR up -- it will mask other \
651-
regressions or improvements in the roll up.
652-
653-
@bors rollup=never
654-
@rustbot label: +S-waiting-on-review -S-waiting-on-perf",
655-
commit.sha, comparison_url, summary
660+
{}
661+
@rustbot label: +S-waiting-on-review -S-waiting-on-perf {}",
662+
commit.sha, comparison_url, summary, rollup, label
656663
),
657664
)
658665
.await;
659666
}
660667
}
661668
}
662669

663-
async fn categorize_benchmark(commit: &database::QueuedCommit, data: &InputData) -> String {
670+
async fn categorize_benchmark(
671+
commit: &database::QueuedCommit,
672+
data: &InputData,
673+
) -> (String, Option<Direction>) {
664674
let comparison = match crate::comparison::compare(
665675
collector::Bound::Commit(commit.parent_sha.clone()),
666676
collector::Bound::Commit(commit.sha.clone()),
@@ -670,25 +680,26 @@ async fn categorize_benchmark(commit: &database::QueuedCommit, data: &InputData)
670680
.await
671681
{
672682
Ok(Some(c)) => c,
673-
_ => return String::from("ERROR categorizing benchmark run!"),
683+
_ => return (String::from("ERROR categorizing benchmark run!"), None),
674684
};
675685
const DISAGREEMENT: &str = "If you disagree with this performance assessment, \
676686
please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
677-
let (summary, direction) =
678-
match crate::comparison::ComparisonSummary::summarize_comparison(&comparison) {
679-
Some(s) if s.direction().is_some() => {
680-
let direction = s.direction().unwrap();
681-
(s, direction)
682-
}
683-
_ => {
684-
return format!(
687+
let (summary, direction) = match ComparisonSummary::summarize_comparison(&comparison) {
688+
Some(s) if s.direction().is_some() => {
689+
let direction = s.direction().unwrap();
690+
(s, direction)
691+
}
692+
_ => {
693+
return (
694+
format!(
685695
"This benchmark run did not return any significant changes.\n\n{}",
686696
DISAGREEMENT
687-
)
688-
}
689-
};
697+
),
698+
None,
699+
)
700+
}
701+
};
690702

691-
use crate::comparison::Direction;
692703
let category = match direction {
693704
Direction::Improvement => "improvements 🎉",
694705
Direction::Regression => "regressions 😿",
@@ -703,5 +714,5 @@ async fn categorize_benchmark(commit: &database::QueuedCommit, data: &InputData)
703714
change.summary_line(&mut result, None)
704715
}
705716
write!(result, "\n{}", DISAGREEMENT).unwrap();
706-
result
717+
(result, Some(direction))
707718
}

0 commit comments

Comments
 (0)