Skip to content

Commit cca4e3d

Browse files
committed
Feat; job_queue table definition & mark a request as complete if all jobs are finished
1 parent 88078cd commit cca4e3d

File tree

6 files changed

+574
-10
lines changed

6 files changed

+574
-10
lines changed

database/schema.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,18 @@ aid benchmark error
258258
---------- --- -----
259259
1 syn-1.0.89 Failed to compile...
260260
```
261+
262+
### job_queue
263+
264+
This table stores ephemeral benchmark jobs, which specifically tell the
265+
collector which benchmarks it should execute. The jobs will be kept in the
266+
table for ~30 days after being completed, so that we can quickly figure out
267+
what master parent jobs we need to backfill when handling try builds.
268+
269+
```
270+
psql# SELECT * FROM job_queue limit 1;
271+
272+
id request_id target backend benchmark_set collector_id created_at started_at completed_at status retry error
273+
--- ----------- -------- -------- ------------- -------------- --------------------------- --------------------------- --------------------------- --------- ------ --------
274+
23 7 AArch64 llvm 5 collector-1 2025-07-10 09:00:00.123+00 2025-07-10 09:05:02.456+00 2025-07-10 09:15:17.890+00 complete 0
275+
```

database/src/lib.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,3 +975,63 @@ impl BenchmarkRequest {
975975
}
976976
}
977977
}
978+
979+
#[derive(Debug, Clone, PartialEq)]
980+
pub enum BenchmarkJobStatus {
981+
Queued,
982+
InProgress,
983+
Success,
984+
Failure,
985+
}
986+
987+
impl BenchmarkJobStatus {
988+
pub fn as_str(&self) -> &str {
989+
match self {
990+
BenchmarkJobStatus::Queued => "queued",
991+
BenchmarkJobStatus::InProgress => "in_progress",
992+
BenchmarkJobStatus::Success => "success",
993+
BenchmarkJobStatus::Failure => "failure",
994+
}
995+
}
996+
}
997+
998+
impl fmt::Display for BenchmarkJobStatus {
999+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1000+
write!(f, "{}", self.as_str())
1001+
}
1002+
}
1003+
1004+
#[derive(Debug, Clone, PartialEq)]
1005+
pub struct BenchmarkJob {
1006+
pub target: Target,
1007+
pub backend: CodegenBackend,
1008+
pub benchmark_set: u32,
1009+
pub collector_id: String,
1010+
pub created_at: Option<DateTime<Utc>>,
1011+
pub started_at: Option<DateTime<Utc>>,
1012+
pub completed_at: Option<DateTime<Utc>>,
1013+
pub status: BenchmarkJobStatus,
1014+
pub retry: u32,
1015+
}
1016+
1017+
impl BenchmarkJob {
1018+
pub fn new(
1019+
target: Target,
1020+
backend: CodegenBackend,
1021+
benchmark_set: u32,
1022+
collector_id: &str,
1023+
status: BenchmarkJobStatus,
1024+
) -> Self {
1025+
BenchmarkJob {
1026+
target,
1027+
backend,
1028+
benchmark_set,
1029+
collector_id: collector_id.to_string(),
1030+
created_at: None,
1031+
started_at: None,
1032+
completed_at: None,
1033+
status,
1034+
retry: 0,
1035+
}
1036+
}
1037+
}

0 commit comments

Comments
 (0)