Skip to content

Commit 518a532

Browse files
committed
Simplify all of the front end transformations, properly order the jobs assigned to a collector
1 parent bfa79d4 commit 518a532

File tree

6 files changed

+201
-174
lines changed

6 files changed

+201
-174
lines changed

database/src/pool/postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@ where
22542254

22552255
fn row_to_benchmark_request(row: &Row, row_offset: Option<usize>) -> BenchmarkRequest {
22562256
let row_offset = row_offset.unwrap_or(0);
2257-
let tag = row.get::<_, Option<String>>(0 + row_offset);
2257+
let tag = row.get::<_, Option<String>>(row_offset);
22582258
let parent_sha = row.get::<_, Option<String>>(1 + row_offset);
22592259
let pr = row.get::<_, Option<i32>>(2 + row_offset);
22602260
let commit_type = row.get::<_, &str>(3 + row_offset);

site/frontend/src/pages/status_new/collector.vue

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<script setup lang="ts">
2-
import {CollectorConfigAndWork, CollectorConfig} from "./data";
2+
import {BenchmarkJob, CollectorInfo, CollectorConfig} from "./data";
33
44
const props = defineProps<{
5-
collector: CollectorConfigAndWork;
5+
collector: CollectorInfo;
6+
jobMap: Dict<BenchmarkJob>;
67
}>();
78
89
function statusClass(c: CollectorConfig): string {
910
return c.isActive ? "active" : "inactive";
1011
}
12+
13+
function getStartedAt(j: BenchmarkJob): string {
14+
return "startedAt" in j.status ? j.status.startedAt : "";
15+
}
1116
</script>
1217

1318
<template>
@@ -55,59 +60,43 @@ function statusClass(c: CollectorConfig): string {
5560
</div>
5661
</div>
5762

58-
<div v-if="collector.request !== null">
59-
<div class="table-collector-wrapper">
60-
<table class="table-collector">
61-
<caption>
62-
current benchmark request
63-
</caption>
64-
<thead>
65-
<tr class="table-header-row">
66-
<th class="table-header-padding">Type</th>
67-
<th class="table-header-padding">Created At</th>
68-
<th class="table-header-padding">Sha / Tag</th>
69-
</tr>
70-
</thead>
71-
<tbody>
72-
<tr>
73-
<td class="table-cell-padding">{{ collector.request.type }}</td>
74-
<td class="table-cell-padding">
75-
{{ collector.request.createdAt }}
76-
</td>
77-
<td class="table-cell-padding">{{ collector.request.tag }}</td>
78-
</tr>
79-
</tbody>
80-
</table>
81-
</div>
82-
83-
<div class="table-collector-wrapper">
84-
<table class="table-collector" style="border-collapse: collapse">
85-
<caption>
86-
current benchmark jobs
87-
</caption>
88-
<thead>
89-
<tr class="table-header-row">
90-
<th class="table-header-padding">State</th>
91-
<th class="table-header-padding">Started At</th>
92-
<th class="table-header-padding">Backend</th>
93-
<th class="table-header-padding">Profile</th>
94-
<th class="table-header-padding">Dequeue Counter</th>
95-
</tr>
96-
</thead>
97-
<tbody>
98-
<tr v-for="j in collector.jobs">
99-
<td class="table-cell-padding">{{ j.state }}</td>
100-
<td class="table-cell-padding">{{ j.startedAt }}</td>
101-
<td class="table-cell-padding">{{ j.backend }}</td>
102-
<td class="table-cell-padding">{{ j.profile }}</td>
103-
<td class="table-cell-padding">{{ j.dequeCounter }}</td>
104-
</tr>
105-
</tbody>
106-
</table>
107-
</div>
63+
<div class="table-collector-wrapper">
64+
<table class="table-collector" style="border-collapse: collapse">
65+
<caption>
66+
current benchmark jobs
67+
</caption>
68+
<thead>
69+
<tr class="table-header-row">
70+
<th class="table-header-padding">Tag / Sha</th>
71+
<th class="table-header-padding">State</th>
72+
<th class="table-header-padding">Started At</th>
73+
<th class="table-header-padding">Backend</th>
74+
<th class="table-header-padding">Profile</th>
75+
<th class="table-header-padding">Dequeue Counter</th>
76+
</tr>
77+
</thead>
78+
<tbody>
79+
<tr v-for="id in collector.jobIds">
80+
<td class="table-cell-padding">
81+
{{ jobMap[id].requestTag }}
82+
</td>
83+
<td class="table-cell-padding">
84+
{{ jobMap[id].status.state }}
85+
</td>
86+
<td class="table-cell-padding">
87+
{{ getStartedAt(jobMap[id]) }}
88+
</td>
89+
<td class="table-cell-padding">{{ jobMap[id].backend }}</td>
90+
<td class="table-cell-padding">{{ jobMap[id].profile }}</td>
91+
<td class="table-cell-padding">
92+
{{ jobMap[id].dequeCounter }}
93+
</td>
94+
</tr>
95+
</tbody>
96+
</table>
10897
</div>
10998

110-
<div class="collector-no-work" v-if="collector.request === null">
99+
<div class="collector-no-work" v-if="collector.jobIds.length === 0">
111100
<h3>no active benchmarks 🦦</h3>
112101
</div>
113102
</div>

site/frontend/src/pages/status_new/data.ts

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -150,87 +150,15 @@ export type CollectorConfig = {
150150
dateAdded: string;
151151
};
152152

153-
export type StatusResponseInProgress = {
154-
request: BenchmarkRequestInProgress;
155-
jobs: BenchmarkJob[];
153+
export type CollectorInfo = {
154+
config: CollectorConfig;
155+
jobIds: number[];
156156
};
157157

158158
export type StatusResponse = {
159-
completed: BenchmarkRequestComplete[];
160-
inProgress: StatusResponseInProgress[];
161-
collectorConfigs: CollectorConfig[];
162-
queue: BenchmarkRequest[];
163-
};
164-
165-
type SimpleJob = {
166-
state: BenchmarkJobStatusStr;
167-
startedAt: string;
168-
backend: string;
169-
profile: string;
170-
dequeCounter: number;
159+
queueRequestTags: string[];
160+
requestsMap: Dict<BenchmarkRequest>;
161+
jobMap: Dict<BenchmarkJob>;
162+
collectorWorkMap: Dict<CollectorInfo>;
163+
tagToJobs: Dict<number[]>;
171164
};
172-
173-
type SimpleRequest = {
174-
type: BenchmarkRequestTypeStr;
175-
tag: string;
176-
createdAt: string;
177-
};
178-
179-
export type CollectorConfigAndWork = {
180-
jobs: SimpleJob[];
181-
config: CollectorConfig;
182-
request: SimpleRequest | null;
183-
};
184-
185-
export type CollectorJobMap = {
186-
[key: string]: CollectorConfigAndWork;
187-
};
188-
189-
/* @TODO; Do this in Rust in the api */
190-
export function createCollectorJobMap(
191-
collectorConfigs: CollectorConfig[],
192-
inProgress: StatusResponseInProgress[]
193-
): CollectorJobMap {
194-
const collectorJobMap: CollectorJobMap = {};
195-
196-
for (const collectorConfig of collectorConfigs) {
197-
collectorJobMap[collectorConfig.name] = {
198-
request: null,
199-
jobs: [],
200-
config: collectorConfig,
201-
};
202-
}
203-
204-
for (const {request, jobs} of inProgress) {
205-
const simpleReq: SimpleRequest = {
206-
type: request.requestType.type,
207-
tag: request.requestType.tag,
208-
createdAt: request.createdAt,
209-
};
210-
for (const j of jobs) {
211-
if (j.status.state !== BenchmarkJobQueued) {
212-
const simpleJob: SimpleJob = {
213-
state: j.status.state,
214-
startedAt: j.status.startedAt,
215-
profile: j.profile,
216-
backend: j.backend,
217-
dequeCounter: j.dequeCounter,
218-
};
219-
if (collectorJobMap[j.status.collectorName].request == null) {
220-
collectorJobMap[j.status.collectorName].request = simpleReq;
221-
}
222-
/* There will be one in_progress job and a few success/failures*/
223-
collectorJobMap[j.status.collectorName].jobs.push(simpleJob);
224-
}
225-
}
226-
}
227-
return collectorJobMap;
228-
}
229-
230-
/* @TODO; Do this in Rust in the api */
231-
export function createTimeline(
232-
completed: BenchmarkRequestComplete[],
233-
queue: BenchmarkRequest[]
234-
) {
235-
return queue.concat(<BenchmarkRequest[]>completed);
236-
}

site/frontend/src/pages/status_new/page.vue

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import {withLoading} from "../../utils/loading";
77
import {formatSecondsAsDuration} from "../../utils/formatting";
88
import {
99
StatusResponse,
10-
CollectorJobMap,
1110
BenchmarkRequestType,
1211
BenchmarkRequest,
12+
BenchmarkJob,
13+
CollectorInfo,
1314
ReleaseCommit,
14-
createCollectorJobMap,
15-
createTimeline,
1615
BenchmarkRequestCompleteStr,
1716
} from "./data";
1817
import Collector from "./collector.vue";
@@ -21,9 +20,12 @@ async function loadStatusNew(loading: Ref<boolean>) {
2120
dataNew.value = await withLoading(loading, async () => {
2221
let d: StatusResponse = await getJson<StatusResponse>(STATUS_DATA_NEW_URL);
2322
return {
24-
queueLength: d.queue.length,
25-
collectorJobMap: createCollectorJobMap(d.collectorConfigs, d.inProgress),
26-
timeline: createTimeline(d.completed, d.queue),
23+
queueLength: d.queueRequestTags.length,
24+
timeline: d.queueRequestTags.map((tag) => d.requestsMap[tag]),
25+
requestsMap: d.requestsMap,
26+
jobMap: d.jobMap,
27+
collectorWorkMap: d.collectorWorkMap,
28+
tagToJobs: d.tagToJobs,
2729
};
2830
});
2931
}
@@ -32,8 +34,11 @@ const loading = ref(true);
3234
/* @TODO; redo type */
3335
const dataNew: Ref<{
3436
queueLength: number;
35-
collectorJobMap: CollectorJobMap;
3637
timeline: BenchmarkRequest[];
38+
requestsMap: Dict<BenchmarkRequest>;
39+
jobMap: Dict<BenchmarkJob>;
40+
collectorWorkMap: Dict<CollectorInfo>;
41+
tagToJobs: Dict<number[]>;
3742
} | null> = ref(null);
3843
3944
function getCreatedAt(request: BenchmarkRequest): string {
@@ -92,7 +97,15 @@ loadStatusNew(loading);
9297
<td>
9398
{{ req.requestType.tag }}
9499
</td>
95-
<td>{{ req.status.state }}</td>
100+
<td>
101+
{{ req.status.state }}
102+
{{
103+
req.status.state === BenchmarkRequestCompleteStr &&
104+
req.requestType.tag in dataNew.tagToJobs
105+
? "*"
106+
: ""
107+
}}
108+
</td>
96109
<td v-html="getCreatedAt(req)"></td>
97110
<td v-html="getDuration(req)"></td>
98111
<td>
@@ -107,10 +120,10 @@ loadStatusNew(loading);
107120
<h1>Collectors</h1>
108121
<div class="collectors-grid">
109122
<div
110-
:key="cc[0]"
111-
v-for="cc in Object.entries(dataNew.collectorJobMap)"
123+
v-for="cc in Object.values(dataNew.collectorWorkMap)"
124+
:key="cc.config.name"
112125
>
113-
<Collector :collector="cc[1]" />
126+
<Collector :jobMap="dataNew.jobMap" :collector="cc" />
114127
</div>
115128
</div>
116129
</div>

site/src/api.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ pub mod status {
394394
pub mod status_new {
395395
use chrono::{DateTime, Utc};
396396
use database::BenchmarkSet;
397+
use hashbrown::HashMap;
397398
use serde::Serialize;
398399

399400
#[derive(Serialize, Debug)]
@@ -454,7 +455,7 @@ pub mod status_new {
454455
pub jobs: Vec<BenchmarkJobUi>,
455456
}
456457

457-
#[derive(Serialize, Debug)]
458+
#[derive(Serialize, Debug, Clone)]
458459
#[serde(rename_all = "camelCase")]
459460
pub struct CollectorConfigUi {
460461
pub name: String,
@@ -465,17 +466,29 @@ pub mod status_new {
465466
pub date_added: DateTime<Utc>,
466467
}
467468

469+
#[derive(Serialize, Debug, Clone)]
470+
#[serde(rename_all = "camelCase")]
471+
pub struct CollectorInfo {
472+
/// Configuration for the collector
473+
pub config: CollectorConfigUi,
474+
/// Jobs that are assigned to the collector from the currently inprogress
475+
/// request and possibly that request's parent.
476+
pub job_ids: Vec<u32>,
477+
}
478+
468479
#[derive(Serialize, Debug)]
469480
#[serde(rename_all = "camelCase")]
470481
pub struct Response {
471-
/// Completed requests alongside any errors
472-
pub completed: Vec<BenchmarkRequestUi>,
473-
/// In progress requests alongside the jobs associated with the request
474-
pub in_progress: Vec<BenchmarkInProgressUi>,
475-
/// Configuration for all collectors including ones that are inactive
476-
pub collector_configs: Vec<CollectorConfigUi>,
477-
/// The current queue
478-
pub queue: Vec<BenchmarkRequestUi>,
482+
/// The current queue, ordered `in_progress`, ... the queue, `completed`
483+
pub queue_request_tags: Vec<String>,
484+
/// Hash table of request tags to requests
485+
pub requests_map: HashMap<String, BenchmarkRequestUi>,
486+
/// Hash table of job ids to jobs
487+
pub job_map: HashMap<u32, BenchmarkJobUi>,
488+
/// Hash table of benchmark set ids to CollectorInfo
489+
pub collector_work_map: HashMap<u32, CollectorInfo>,
490+
/// Request tag to a vector of job ids
491+
pub tag_to_jobs: HashMap<String, Vec<u32>>,
479492
}
480493
}
481494

0 commit comments

Comments
 (0)