Skip to content

Commit 375af64

Browse files
Merge pull request #1563 from rust-lang/proper-end-check
Correct checking of end bound for triage comparison
2 parents c53640e + 4f6e505 commit 375af64

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

site/src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ pub mod triage {
448448
#[derive(Debug, Clone, Serialize, Deserialize)]
449449
pub struct Request {
450450
pub start: Bound,
451-
pub end: Option<Bound>,
451+
pub end: Bound,
452452
}
453453

454454
#[derive(Debug, Clone, Serialize, Deserialize)]

site/src/comparison.rs

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,29 @@ pub async fn handle_triage(
4949
let mut num_comparisons = 0;
5050
let metric = Metric::InstructionsUser;
5151
let benchmark_map = ctxt.get_benchmark_category_map().await;
52-
loop {
53-
let comparison =
54-
match compare_given_commits(before, next.clone(), metric, ctxt, &master_commits)
55-
.await
56-
.map_err(|e| format!("error comparing commits: {}", e))?
57-
{
58-
Some(c) => c,
59-
None => {
60-
log::info!(
61-
"No data found for end bound {:?}. Ending comparison...",
62-
next
63-
);
64-
break;
65-
}
66-
};
52+
// Track whether we are on the known last iteration
53+
let mut last_iteration = false;
54+
55+
let end = loop {
56+
let comparison = match compare_given_commits(
57+
before.clone(),
58+
next.clone(),
59+
metric,
60+
ctxt,
61+
&master_commits,
62+
)
63+
.await
64+
.map_err(|e| format!("error comparing commits: {}", e))?
65+
{
66+
Some(c) => c,
67+
None => {
68+
log::info!(
69+
"No data found for end bound {:?}. Ending comparison...",
70+
next
71+
);
72+
break before;
73+
}
74+
};
6775
num_comparisons += 1;
6876
log::info!(
6977
"Comparing {} to {}",
@@ -74,17 +82,25 @@ pub async fn handle_triage(
7482
// handle results of comparison
7583
populate_report(&comparison, &benchmark_map, &mut report).await;
7684

77-
// Check that there is a next commit and that the
78-
// after commit is not equal to `end`
85+
// If we already know this is the last iteration, we can stop
86+
if last_iteration {
87+
break before;
88+
}
89+
90+
// Decide whether to keep doing comparisons or not
7991
match comparison.next(&master_commits).map(Bound::Commit) {
80-
Some(n) if Some(&next) != end.as_ref() => {
92+
// There is a next commit, and it is not the end bound.
93+
// We keep doing comparisons...
94+
Some(n) => {
8195
before = next;
96+
// The next iteration is the last if the next bound is equal to the end bound
97+
last_iteration = n != end;
8298
next = n;
8399
}
84-
_ => break,
100+
// There is no next commit so we stop.
101+
None => break before,
85102
}
86-
}
87-
let end = end.unwrap_or(next);
103+
};
88104

89105
// Summarize the entire triage from start commit to end commit
90106
let summary =

0 commit comments

Comments
 (0)