Skip to content

Commit 3e1489a

Browse files
committed
Feat; job_queue table definition & mark a request as complete if all jobs are finished
1 parent d3c010b commit 3e1489a

File tree

6 files changed

+605
-12
lines changed

6 files changed

+605
-12
lines changed

database/schema.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ aid benchmark error
259259
1 syn-1.0.89 Failed to compile...
260260
```
261261

262-
263262
## New benchmarking design
264263
We are currently implementing a new design for dispatching benchmarks to collector(s) and storing
265264
them in the database. It will support new use-cases, like backfilling of new benchmarks into a parent
@@ -296,3 +295,19 @@ Columns:
296295
* `completed`: Completed request.
297296
* **backends** (`text NOT NULL`): Comma-separated list of codegen backends to benchmark. If empty, the default set of codegen backends will be benchmarked.
298297
* **profiles** (`text NOT NULL`): Comma-separated list of profiles to benchmark. If empty, the default set of profiles will be benchmarked.
298+
||||||| parent of cca4e3d5 (Feat; job_queue table definition & mark a request as complete if all jobs are finished)
299+
300+
### job_queue
301+
302+
This table stores ephemeral benchmark jobs, which specifically tell the
303+
collector which benchmarks it should execute. The jobs will be kept in the
304+
table for ~30 days after being completed, so that we can quickly figure out
305+
what master parent jobs we need to backfill when handling try builds.
306+
307+
```
308+
psql# SELECT * FROM job_queue limit 1;
309+
310+
id request_id target backend benchmark_set collector_id created_at started_at completed_at status retry error
311+
--- ----------- -------- -------- ------------- -------------- --------------------------- --------------------------- --------------------------- --------- ------ --------
312+
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
313+
```

database/src/lib.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,10 @@ impl BenchmarkRequest {
988988
pub fn is_release(&self) -> bool {
989989
matches!(self.commit_type, BenchmarkRequestType::Release { .. })
990990
}
991+
992+
pub fn is_completed(&self) -> bool {
993+
matches!(self.status, BenchmarkRequestStatus::Completed { .. })
994+
}
991995
}
992996

993997
/// Cached information about benchmark requests in the DB
@@ -1009,4 +1013,68 @@ impl BenchmarkRequestIndex {
10091013
pub fn completed_requests(&self) -> &HashSet<String> {
10101014
&self.completed
10111015
}
1016+
1017+
pub fn add_tag(&mut self, tag: &str) {
1018+
self.completed.insert(tag.to_string());
1019+
}
1020+
}
1021+
1022+
#[derive(Debug, Clone, PartialEq)]
1023+
pub enum BenchmarkJobStatus {
1024+
Queued,
1025+
InProgress,
1026+
Success,
1027+
Failure,
1028+
}
1029+
1030+
impl BenchmarkJobStatus {
1031+
pub fn as_str(&self) -> &str {
1032+
match self {
1033+
BenchmarkJobStatus::Queued => "queued",
1034+
BenchmarkJobStatus::InProgress => "in_progress",
1035+
BenchmarkJobStatus::Success => "success",
1036+
BenchmarkJobStatus::Failure => "failure",
1037+
}
1038+
}
1039+
}
1040+
1041+
impl fmt::Display for BenchmarkJobStatus {
1042+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1043+
write!(f, "{}", self.as_str())
1044+
}
1045+
}
1046+
1047+
#[derive(Debug, Clone, PartialEq)]
1048+
pub struct BenchmarkJob {
1049+
pub target: Target,
1050+
pub backend: CodegenBackend,
1051+
pub benchmark_set: u32,
1052+
pub collector_id: String,
1053+
pub created_at: Option<DateTime<Utc>>,
1054+
pub started_at: Option<DateTime<Utc>>,
1055+
pub completed_at: Option<DateTime<Utc>>,
1056+
pub status: BenchmarkJobStatus,
1057+
pub retry: u32,
1058+
}
1059+
1060+
impl BenchmarkJob {
1061+
pub fn new(
1062+
target: Target,
1063+
backend: CodegenBackend,
1064+
benchmark_set: u32,
1065+
collector_id: &str,
1066+
status: BenchmarkJobStatus,
1067+
) -> Self {
1068+
BenchmarkJob {
1069+
target,
1070+
backend,
1071+
benchmark_set,
1072+
collector_id: collector_id.to_string(),
1073+
created_at: None,
1074+
started_at: None,
1075+
completed_at: None,
1076+
status,
1077+
retry: 0,
1078+
}
1079+
}
10121080
}

0 commit comments

Comments
 (0)