Skip to content

Commit 577c0fa

Browse files
committed
Only show categorize changes on master runs when they are definitely relevant
1 parent e190d43 commit 577c0fa

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

site/src/github.rs

Lines changed: 21 additions & 5 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,8 +560,13 @@ 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;
565570

566571
let mut label = String::new();
567572
if !is_master_commit {
@@ -634,9 +639,10 @@ for rolling up. "
634639
}
635640

636641
async fn categorize_benchmark(
642+
ctxt: &SiteCtxt,
637643
commit_sha: String,
638644
parent_sha: String,
639-
ctxt: &SiteCtxt,
645+
is_master_commit: bool,
640646
) -> (String, Option<Direction>) {
641647
let comparison = match crate::comparison::compare(
642648
collector::Bound::Commit(parent_sha),
@@ -653,7 +659,7 @@ async fn categorize_benchmark(
653659
please file an issue in [rust-lang/rustc-perf](https://github.com/rust-lang/rustc-perf/issues/new).";
654660
let (summary, (direction, magnitude)) =
655661
match ComparisonSummary::summarize_comparison(&comparison) {
656-
Some(s) if s.confidence().is_atleast_probably_relevant() => {
662+
Some(s) if comparison_is_relevant(s.confidence(), is_master_commit) => {
657663
let direction_and_magnitude = s.direction_and_magnitude().unwrap();
658664
(s, direction_and_magnitude)
659665
}
@@ -686,6 +692,16 @@ async fn categorize_benchmark(
686692
(result, Some(direction))
687693
}
688694

695+
/// Whether a comparison is relevant enough to show
696+
fn comparison_is_relevant(confidence: ComparisonConfidence, is_master_commit: bool) -> bool {
697+
if is_master_commit {
698+
confidence.is_definitely_relevant()
699+
} else {
700+
// is try run
701+
confidence.is_atleast_probably_relevant()
702+
}
703+
}
704+
689705
pub(crate) struct PullRequest {
690706
pub number: u64,
691707
pub title: String,

0 commit comments

Comments
 (0)