Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions site/frontend/templates/pages/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@ <h3><b><code>@rust-timer</code> commands</b></h3>
"try" run's commit for the <code>build</code> command)
This command also supports the same options as <code>@rust-timer queue</code>.
</p>
<p><code>@rust-timer triage $commits</code> is meant to be executed on a rollup,
to help identify the culprit of performance regressions/improvements of that rollup.
It takes a space-separated list of `$commits` SHAs, and queues a perf run for each commit.
The results are reported on the corresponding PRs, and in the future will also be reported in the rollup itself.
This command does not (yet) support options.
</p>
</div>
{% endblock %}
114 changes: 50 additions & 64 deletions site/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,80 +226,66 @@ pub async fn rollup_pr_number(
.then_some(issue.number))
}

/// Enqueues the given SHAs and returns the SHAs that were actually enqueued.
pub async fn enqueue_shas<'a>(
/// Enqueues the given SHA and returns a message that should be sent as a comment to the corresponding PR.
pub async fn enqueue_sha(
ctxt: &SiteCtxt,
gh_client: &client::Client,
pr_number: u32,
commits: impl Iterator<Item = &'a str>,
) -> Result<Vec<&'a str>, String> {
let mut enqueued = vec![];
let mut msg = String::new();
for commit in commits {
let mut commit_response = gh_client
.get_commit(commit)
.await
.map_err(|e| e.to_string())?;
if commit_response.parents.len() != 2 {
log::error!(
"Bors try commit {} unexpectedly has {} parents.",
commit_response.sha,
commit_response.parents.len()
);
continue;
}
let try_commit = TryCommit {
sha: commit_response.sha,
parent_sha: commit_response.parents.remove(0).sha,
};
let conn = ctxt.conn().await;
commit_sha: &str,
) -> Result<String, String> {
let mut commit = gh_client
.get_commit(commit_sha)
.await
.map_err(|e| e.to_string())?;
if commit.parents.len() != 2 {
return Err(format!(
"Bors try commit {} unexpectedly has {} parents.",
commit.sha,
commit.parents.len()
));
}
let try_commit = TryCommit {
sha: commit.sha,
parent_sha: commit.parents.remove(0).sha,
};
let conn = ctxt.conn().await;

let queued = conn.attach_shas_to_try_benchmark_request(
pr_number,
&try_commit.sha,
&try_commit.parent_sha,
commit_response.commit.committer.date,
let queued = conn.attach_shas_to_try_benchmark_request(
pr_number,
&try_commit.sha,
&try_commit.parent_sha,
commit.commit.committer.date,
)
.await
.map_err(|error| format!("Cannot attach SHAs to try benchmark request on PR {pr_number} and SHA {}: {error:?}", try_commit.sha))?;
if queued {
enqueued.push(commit);
if !msg.is_empty() {
msg.push('\n');
}

let (preceding_artifacts, expected_duration) =
estimate_queue_info(conn.as_ref(), &try_commit)
.await
.map_err(|e| format!("{e:?}"))?;

let verb = if preceding_artifacts == 1 {
"is"
} else {
"are"
};
let suffix = if preceding_artifacts == 1 { "" } else { "s" };
let queue_msg = format!(
r#"There {verb} currently {preceding_artifacts} preceding artifact{suffix} in the [queue](https://perf.rust-lang.org/status.html).
It will probably take at least ~{:.1} hours until the benchmark run finishes."#,
expected_duration.as_secs_f64() / 3600.0
);

msg.push_str(&format!(
"Queued {} with parent {}, future [comparison URL]({}).\n{queue_msg}",
try_commit.sha,
try_commit.parent_sha,
try_commit.comparison_url(),
));
}
if !queued {
return Err(
"Commit was not enqueued, since no previous benchmark request was found".to_string(),
);
}

if !msg.is_empty() {
msg.push_str(&format!("\n{COMMENT_MARK_TEMPORARY}"));
gh_client.post_comment(pr_number, msg).await;
}
let (preceding_artifacts, expected_duration) = estimate_queue_info(conn.as_ref(), &try_commit)
.await
.map_err(|e| format!("{e:?}"))?;

Ok(enqueued)
let verb = if preceding_artifacts == 1 {
"is"
} else {
"are"
};
let suffix = if preceding_artifacts == 1 { "" } else { "s" };
let queue_msg = format!(
r#"There {verb} currently {preceding_artifacts} preceding artifact{suffix} in the [queue](https://perf.rust-lang.org/status.html).
It will probably take at least ~{:.1} hours until the benchmark run finishes."#,
expected_duration.as_secs_f64() / 3600.0
);

Ok(format!(
"Queued {} with parent {}, future [comparison URL]({}).\n{queue_msg}",
try_commit.sha,
try_commit.parent_sha,
try_commit.comparison_url(),
))
}

/// Counts how many artifacts are in the queue before the specified commit, and what is the expected
Expand Down
Loading
Loading