Skip to content

Commit d7f85aa

Browse files
authored
Merge pull request #993 from rylev/post-merge-improvements
Post merge improvements
2 parents dfffe9a + f63b797 commit d7f85aa

File tree

1 file changed

+86
-54
lines changed

1 file changed

+86
-54
lines changed

site/src/github.rs

Lines changed: 86 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::api::github::Issue;
2-
use crate::comparison::{ComparisonSummary, Direction};
2+
use crate::comparison::{ComparisonConfidence, ComparisonSummary, Direction};
33
use crate::load::{Config, SiteCtxt, TryCommit};
44

55
use anyhow::Context as _;
@@ -560,75 +560,97 @@ async fn post_comparison_comment(ctxt: &SiteCtxt, commit: QueuedCommit, is_maste
560560
"https://perf.rust-lang.org/compare.html?start={}&end={}",
561561
commit.parent_sha, commit.sha
562562
);
563-
let (summary, direction) =
564-
categorize_benchmark(commit.sha.clone(), commit.parent_sha, ctxt).await;
563+
let (summary, direction) = categorize_benchmark(
564+
ctxt,
565+
commit.sha.clone(),
566+
commit.parent_sha,
567+
is_master_commit,
568+
)
569+
.await;
570+
571+
let body = format!(
572+
"Finished benchmarking commit ({sha}): [comparison url]({url}).
573+
574+
**Summary**: {summary}
575+
{rest}",
576+
sha = commit.sha,
577+
url = comparison_url,
578+
summary = summary,
579+
rest = if is_master_commit {
580+
master_run_body(direction)
581+
} else {
582+
try_run_body(direction)
583+
}
584+
);
585+
586+
post_comment(&ctxt.config, commit.pr, body).await;
587+
}
588+
589+
fn master_run_body(direction: Option<Direction>) -> String {
565590
let label = match direction {
566591
Some(Direction::Regression | Direction::Mixed) => "+perf-regression",
567592
Some(Direction::Improvement) | None => "-perf-regression",
568593
};
569-
let rollup_msg = if is_master_commit {
570-
""
571-
} else {
572-
"Benchmarking this pull request likely means that it is \
573-
perf-sensitive, so we're automatically marking it as not fit \
574-
for rolling up. "
575-
};
576-
let next_steps_msg = direction
577-
.map(|d| {
578-
format!(
579-
"{}{}",
580-
if is_master_commit {
581-
""
582-
} else {
583-
"While you can manually mark this PR as fit \
584-
for rollup, we strongly recommend not doing so since this PR led to changes in \
585-
compiler perf."
586-
},
587-
match d {
588-
Direction::Regression | Direction::Mixed =>
589-
"\n\n**Next Steps**: If you can justify the \
594+
let next_steps = match direction {
595+
Some(Direction::Regression | Direction::Mixed) => {
596+
"\n\n**Next Steps**: If you can justify the \
590597
regressions found in this perf run, please indicate this with \
591598
`@rustbot label: +perf-regression-triaged` along with \
592599
sufficient written justification. If you cannot justify the regressions \
593-
please fix the regressions (either in this PR if it's not yet merged or \
594-
in another PR), and then add the `perf-regression-triaged` label to this PR.",
595-
Direction::Improvement => "",
596-
}
597-
)
598-
})
599-
.unwrap_or(String::new());
600-
let bors_msg = if is_master_commit {
601-
""
602-
} else {
603-
"@bors rollup=never\n"
600+
please open an issue or create a new PR that fixes the regressions, \
601+
add a comment linking to the newly created issue or PR, \
602+
and then add the `perf-regression-triaged` label to this PR."
603+
}
604+
Some(Direction::Improvement) | None => "",
604605
};
605-
post_comment(
606-
&ctxt.config,
607-
commit.pr,
608-
format!(
609-
"Finished benchmarking commit ({sha}): [comparison url]({url}).
610606

611-
**Summary**: {summary}
607+
format!(
608+
"
609+
{next_steps}
610+
611+
@rustbot label: {label}",
612+
next_steps = next_steps,
613+
label = label
614+
)
615+
}
616+
617+
fn try_run_body(direction: Option<Direction>) -> String {
618+
let label = match direction {
619+
Some(Direction::Regression | Direction::Mixed) => "+perf-regression",
620+
Some(Direction::Improvement) | None => "-perf-regression",
621+
};
622+
let next_steps = match direction {
623+
Some(Direction::Regression | Direction::Mixed) => {
624+
"\n\n**Next Steps**: If you can justify the regressions found in \
625+
this try perf run, please indicate this with \
626+
`@rustbot label: +perf-regression-triaged` along with \
627+
sufficient written justification. If you cannot justify the regressions \
628+
please fix the regressions and do another perf run. If the next run \
629+
shows neutral or positive results, the label will be automatically removed."
630+
}
631+
Some(Direction::Improvement) | None => "",
632+
};
612633

613-
{rollup}{next_steps}
614-
{bors}
634+
format!(
635+
"
636+
Benchmarking this pull request likely means that it is \
637+
perf-sensitive, so we're automatically marking it as not fit \
638+
for rolling up. While you can manually mark this PR as fit \
639+
for rollup, we strongly recommend not doing so since this PR led to changes in \
640+
compiler perf.{next_steps}
641+
642+
@bors rollup=never
615643
@rustbot label: +S-waiting-on-review -S-waiting-on-perf {label}",
616-
sha = commit.sha,
617-
url = comparison_url,
618-
summary = summary,
619-
rollup = rollup_msg,
620-
next_steps = next_steps_msg,
621-
bors = bors_msg,
622-
label = label
623-
),
644+
next_steps = next_steps,
645+
label = label
624646
)
625-
.await;
626647
}
627648

628649
async fn categorize_benchmark(
650+
ctxt: &SiteCtxt,
629651
commit_sha: String,
630652
parent_sha: String,
631-
ctxt: &SiteCtxt,
653+
is_master_commit: bool,
632654
) -> (String, Option<Direction>) {
633655
let comparison = match crate::comparison::compare(
634656
collector::Bound::Commit(parent_sha),
@@ -645,7 +667,7 @@ async fn categorize_benchmark(
645667
please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
646668
let (summary, (direction, magnitude)) =
647669
match ComparisonSummary::summarize_comparison(&comparison) {
648-
Some(s) if s.confidence().is_atleast_probably_relevant() => {
670+
Some(s) if comparison_is_relevant(s.confidence(), is_master_commit) => {
649671
let direction_and_magnitude = s.direction_and_magnitude().unwrap();
650672
(s, direction_and_magnitude)
651673
}
@@ -678,6 +700,16 @@ async fn categorize_benchmark(
678700
(result, Some(direction))
679701
}
680702

703+
/// Whether a comparison is relevant enough to show
704+
fn comparison_is_relevant(confidence: ComparisonConfidence, is_master_commit: bool) -> bool {
705+
if is_master_commit {
706+
confidence.is_definitely_relevant()
707+
} else {
708+
// is try run
709+
confidence.is_atleast_probably_relevant()
710+
}
711+
}
712+
681713
pub(crate) struct PullRequest {
682714
pub number: u64,
683715
pub title: String,

0 commit comments

Comments
 (0)