10000 Refactor benchmark requests by Kobzol · Pull Request #2201 · rust-lang/rustc-perf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Create dedicated function for creating try requests without artifacts
  • Loading branch information
Kobzol committed Jul 10, 2025
commit 10904fcb4e2c47f8a4bd4195e01b164048c6fe15
14 changes: 5 additions & 9 deletions database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,6 @@ impl fmt::Display for BenchmarkRequestStatus {
}
}



const BENCHMARK_REQUEST_TRY_STR: &str = "try";
const BENCHMARK_REQUEST_MASTER_STR: &str = "master";
const BENCHMARK_REQUEST_RELEASE_STR: &str = "release";
Expand Down Expand Up @@ -912,23 +910,21 @@ impl BenchmarkRequest {
}
}

pub fn create_try(
sha: Option<&str>,
parent_sha: Option<&str>,
/// Create a try request that is waiting for artifacts
pub fn create_try_without_artifacts(
pr: u32,
created_at: DateTime<Utc>,
status: BenchmarkRequestStatus,
backends: &str,
profiles: &str,
) -> Self {
Self {
commit_type: BenchmarkRequestType::Try {
pr,
sha: sha.map(|it| it.to_string()),
parent_sha: parent_sha.map(|it| it.to_string()),
sha: None,
parent_sha: None,
},
created_at,
status,
status: BenchmarkRequestStatus::WaitingForArtifacts,
backends: backends.to_string(),
profiles: profiles.to_string(),
}
Expand Down
25 changes: 9 additions & 16 deletions site/src/request_handlers/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::github::{
use crate::job_queue::run_new_queue;
use crate::load::SiteCtxt;

use database::{BenchmarkRequest, BenchmarkRequestStatus};
use database::BenchmarkRequest;
use hashbrown::HashMap;
use std::sync::Arc;

Expand Down Expand Up @@ -74,25 +74,18 @@ async fn handle_issue(
Ok(github::Response)
}

/// The try does not have a `sha` or a `parent_sha` but we need to keep a record
/// of this commit existing. We make sure there can only be one `pr` with a
/// status of `WaitingForArtifacts` to ensure we don't have duplicates.
async fn queue_partial_try_benchmark_request(
/// The try request does not have a `sha` or a `parent_sha` but we need to keep a record
/// of this commit existing. The DB ensures that there is only one non-completed
/// try benchmark request per `pr`.
async fn record_try_benchmark_request_without_artifacts(
conn: &dyn database::pool::Connection,
pr: u32,
backends: &str,
) {
// We only want to run this if the new system is running
if run_new_queue() {
let try_request = BenchmarkRequest::create_try(
None,
None,
pr,
chrono::Utc::now(),
8000 BenchmarkRequestStatus::WaitingForArtifacts,
backends,
"",
);
let try_request =
BenchmarkRequest::create_try_without_artifacts(pr, chrono::Utc::now(), backends, "");
if let Err(e) = conn.insert_benchmark_request(&try_request).await {
log::error!("Failed to insert try benchmark request: {}", e);
}
Expand Down Expand Up @@ -125,7 +118,7 @@ async fn handle_rust_timer(
Ok(cmd) => {
let conn = ctxt.conn().await;

queue_partial_try_benchmark_request(
record_try_benchmark_request_without_artifacts(
&*conn,
issue.number,
cmd.params.backends.unwrap_or(""),
Expand Down Expand Up @@ -171,7 +164,7 @@ async fn handle_rust_timer(
{
let conn = ctxt.conn().await;
for command in &valid_build_cmds {
queue_partial_try_benchmark_request(
record_try_benchmark_request_without_artifacts(
&*conn,
issue.number,
command.params.backends.unwrap_or(""),
Expand Down
0