Skip to content

Commit 2120e3b

Browse files
authored
Merge pull request #2157 from Jamesbarford/feat/collector-config-table
Feat; Create new table for collector configuration
2 parents c499665 + 2e7ced8 commit 2120e3b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

database/schema.md

Lines changed: 18 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,21 @@ 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+
299+
### collector_config
300+
301+
Information about the collector; it's target architecture, when it was added,
302+
whether it is active and when it last had activity denoted by `last_heartbeat_at`.
303+
304+
Columns:
305+
306+
* **id** (`id`): A unique identifier for the collector.
307+
* **target** (`text NOT NULL`): The ISA of the collector for example; `aarch64-unknown-linux-gnu`.
308+
* **name** (`text NOT NULL`): Unique name for the collector.
309+
* **date_added** (`timestamptz NOT NULL`): When the collector was added
310+
* **last_heartbeat_at** (`timestamptz`): When the collector last updated this
311+
column, a way to test if the collector is still alive.
312+
* **benchmark_set** (`int NOT NULL`): ID of the predefined benchmark suite to
313+
execute.
314+
* **is_active** (`boolean NOT NULL`): For controlling whether the collector is
315+
active for use. Useful for adding/removing collectors.

database/src/pool/postgres.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,21 @@ static MIGRATIONS: &[&str] = &[
309309
// Prevent multiple try commits without a `sha` and the same `pr` number
310310
// being added to the table
311311
r#"CREATE UNIQUE INDEX benchmark_request_pr_commit_type_idx ON benchmark_request (pr, commit_type) WHERE status != 'completed';"#,
312+
r#"
313+
CREATE TABLE IF NOT EXISTS collector_config (
314+
id SERIAL PRIMARY KEY,
315+
target TEXT NOT NULL,
316+
name TEXT NOT NULL UNIQUE,
317+
date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL,
318+
last_heartbeat_at TIMESTAMPTZ,
319+
benchmark_set INTEGER NOT NULL,
320+
is_active BOOLEAN DEFAULT FALSE NOT NULL
321+
);
322+
-- Given the current setup, we do not want 2 collectors that are active
323+
-- with the same target using the same benchmark set.
324+
CREATE UNIQUE INDEX collector_config_target_bench_active_uniq ON collector_config
325+
(target, benchmark_set, is_active) WHERE is_active = TRUE;
326+
"#,
312327
];
313328

314329
#[async_trait::async_trait]

0 commit comments

Comments
 (0)