Skip to content

Commit 75d14ff

Browse files
committed
Don't return master commits as try commit
1 parent f78ebf6 commit 75d14ff

File tree

3 files changed

+59
-48
lines changed

3 files changed

+59
-48
lines changed

site/src/github.rs

+43-30
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ pub struct PostComment {
501501
pub body: String,
502502
}
503503

504+
/// Post messages to GitHub for all queued commits that have
505+
/// not yet been marked as completed.
504506
pub async fn post_finished(ctxt: &SiteCtxt) {
505507
// If the github token is not configured, do not run this -- we don't want
506508
// to mark things as complete without posting the comment.
@@ -509,7 +511,7 @@ pub async fn post_finished(ctxt: &SiteCtxt) {
509511
}
510512
let conn = ctxt.conn().await;
511513
let index = ctxt.index.load();
512-
let mut already_tested_commits = index
514+
let mut known_commits = index
513515
.commits()
514516
.into_iter()
515517
.map(|c| c.sha.to_string())
@@ -519,36 +521,41 @@ pub async fn post_finished(ctxt: &SiteCtxt) {
519521
conn.queued_commits(),
520522
conn.in_progress_artifacts()
521523
);
522-
let master_commits = master_commits
523-
.unwrap()
524-
.into_iter()
525-
.map(|c| c.sha)
526-
.collect::<HashSet<_>>();
524+
let master_commits = if let Ok(mcs) = master_commits {
525+
mcs.into_iter().map(|c| c.sha).collect::<HashSet<_>>()
526+
} else {
527+
// If we can't fetch master commits, return.
528+
// We'll eventually try again later
529+
return;
530+
};
527531

528532
for aid in in_progress_artifacts {
529533
match aid {
530534
ArtifactId::Commit(c) => {
531-
already_tested_commits.remove(&c.sha);
535+
known_commits.remove(&c.sha);
532536
}
533537
ArtifactId::Tag(_) => {
534538
// do nothing, for now, though eventually we'll want an artifact queue
535539
}
536540
}
537541
}
538-
for commit in queued_pr_commits
542+
for queued_commit in queued_pr_commits
539543
.into_iter()
540-
.filter(|c| already_tested_commits.contains(&c.sha))
544+
.filter(|c| known_commits.contains(&c.sha))
541545
{
542-
if let Some(completed) = conn.mark_complete(&commit.sha).await {
543-
assert_eq!(completed, commit);
546+
if let Some(completed) = conn.mark_complete(&queued_commit.sha).await {
547+
assert_eq!(completed, queued_commit);
544548

545-
let is_master_commit = master_commits.contains(&commit.sha);
546-
post_comparison_comment(commit, ctxt, is_master_commit).await;
549+
let is_master_commit = master_commits.contains(&queued_commit.sha);
550+
post_comparison_comment(ctxt, queued_commit, is_master_commit).await;
547551
}
548552
}
549553
}
550554

551-
async fn post_comparison_comment(commit: QueuedCommit, ctxt: &SiteCtxt, is_master_commit: bool) {
555+
/// Posts a comment to GitHub summarizing the comparison of the queued commit with its parent
556+
///
557+
/// `is_master_commit` is used to differentiate messages for try runs and post-merge runs.
558+
async fn post_comparison_comment(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit: bool) {
552559
let comparison_url = format!(
553560
"https://perf.rust-lang.org/compare.html?start={}&end={}",
554561
commit.parent_sha, commit.sha
@@ -559,6 +566,13 @@ async fn post_comparison_comment(commit: QueuedCommit, ctxt: &SiteCtxt, is_maste
559566
Some(Direction::Regression | Direction::Mixed) => "+perf-regression",
560567
Some(Direction::Improvement) | None => "-perf-regression",
561568
};
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+
};
562576
let next_steps_msg = direction
563577
.map(|d| {
564578
format!(
@@ -577,19 +591,12 @@ async fn post_comparison_comment(commit: QueuedCommit, ctxt: &SiteCtxt, is_maste
577591
`@rustbot label: +perf-regression-triaged` along with \
578592
sufficient written justification. If you cannot justify the regressions \
579593
please fix the regressions (either in this PR if it's not yet merged or \
580-
in another PR) and do another perf run.",
594+
in another PR), and then add the `perf-regression-triaged` label to this PR.",
581595
Direction::Improvement => "",
582596
}
583597
)
584598
})
585599
.unwrap_or(String::new());
586-
let rollup_msg = if is_master_commit {
587-
""
588-
} else {
589-
"Benchmarking this pull request likely means that it is \
590-
perf-sensitive, so we're automatically marking it as not fit \
591-
for rolling up. "
592-
};
593600
let bors_msg = if is_master_commit {
594601
""
595602
} else {
@@ -599,14 +606,20 @@ for rolling up. "
599606
&ctxt.config,
600607
commit.pr,
601608
format!(
602-
"Finished benchmarking commit ({}): [comparison url]({}).
603-
604-
**Summary**: {}
605-
606-
{}{}
607-
{}
608-
@rustbot label: +S-waiting-on-review -S-waiting-on-perf {}",
609-
commit.sha, comparison_url, summary, rollup_msg, next_steps_msg, bors_msg, label
609+
"Finished benchmarking commit ({sha}): [comparison url]({url}).
610+
611+
**Summary**: {summary}
612+
613+
{rollup}{next_steps}
614+
{bors}
615+
@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
610623
),
611624
)
612625
.await;

site/src/load.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ pub enum MissingReason {
3535
InProgress(Option<Box<MissingReason>>),
3636
}
3737

38-
impl MissingReason {
39-
/// If the commit is a master commit get its PR and parent_sha
40-
pub fn master_commit_pr_and_parent(&self) -> Option<(u32, &str)> {
41-
match self {
42-
Self::Master { pr, parent_sha } => Some((*pr, parent_sha)),
43-
_ => None,
44-
}
45-
}
46-
}
47-
4838
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq)]
4939
pub struct TryCommit {
5040
pub sha: String,
@@ -156,9 +146,10 @@ impl SiteCtxt {
156146
self.pool.connection().await
157147
}
158148

149+
/// Returns the not yet tested commits
159150
pub async fn missing_commits(&self) -> Vec<(Commit, MissingReason)> {
160151
let conn = self.conn().await;
161-
let (master_commits, queued_try_commits, in_progress_artifacts) = futures::join!(
152+
let (master_commits, queued_pr_commits, in_progress_artifacts) = futures::join!(
162153
collector::master_commits(),
163154
conn.queued_commits(),
164155
conn.in_progress_artifacts()
@@ -195,15 +186,18 @@ impl SiteCtxt {
195186
.collect::<Vec<_>>();
196187
master_commits.reverse();
197188

198-
let mut missing = Vec::with_capacity(queued_try_commits.len() * 2 + master_commits.len()); // Two commits per every try commit and all master commits
189+
let mut missing = Vec::with_capacity(queued_pr_commits.len() * 2 + master_commits.len()); // Two commits per every try commit and all master commits
199190
for database::QueuedCommit {
200191
sha,
201192
parent_sha,
202193
pr,
203194
include,
204195
exclude,
205196
runs,
206-
} in queued_try_commits
197+
} in queued_pr_commits
198+
.into_iter()
199+
// filter out any queued PR master commits (leaving only try commits)
200+
.filter(|c| !master_commits.iter().any(|(mc, _)| mc.sha == c.sha))
207201
{
208202
// Enqueue the `TryParent` commit before the `TryCommit` itself, so that
209203
// all of the `try` run's data is complete when the benchmark results

site/src/request_handlers/next_commit.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
use crate::load::SiteCtxt;
1+
use crate::load::{MissingReason, SiteCtxt};
22
use collector::api::next_commit;
33

44
use std::sync::Arc;
55

66
pub async fn handle_next_commit(ctxt: Arc<SiteCtxt>) -> next_commit::Response {
7-
let commit = ctxt.missing_commits().await.into_iter().next();
7+
let next_commit = ctxt.missing_commits().await.into_iter().next();
88

9-
let commit = if let Some((commit, missing_reason)) = commit {
9+
let next_commit = if let Some((commit, missing_reason)) = next_commit {
1010
// If we're going to run a master commit next, make sure
1111
// it's been enqueued in the pull_request_build table
12-
if let Some((pr, parent_sha)) = missing_reason.master_commit_pr_and_parent() {
12+
if let MissingReason::Master { pr, ref parent_sha } = missing_reason {
1313
let conn = ctxt.conn().await;
14+
// TODO: add capability of doing the following in one step
15+
// to avoid possibile illegal inbetween states.
1416
conn.queue_pr(pr, None, None, None).await;
1517
conn.pr_attach_commit(pr, &commit.sha, parent_sha).await;
1618
}
@@ -46,5 +48,7 @@ pub async fn handle_next_commit(ctxt: Arc<SiteCtxt>) -> next_commit::Response {
4648
None
4749
};
4850

49-
next_commit::Response { commit }
51+
next_commit::Response {
52+
commit: next_commit,
53+
}
5054
}

0 commit comments

Comments
 (0)