diff --git a/database/schema.md b/database/schema.md index 6c8194d7d..9ae0045cc 100644 --- a/database/schema.md +++ b/database/schema.md @@ -259,7 +259,6 @@ aid benchmark error 1 syn-1.0.89 Failed to compile... ``` - ## New benchmarking design We are currently implementing a new design for dispatching benchmarks to collector(s) and storing them in the database. It will support new use-cases, like backfilling of new benchmarks into a parent @@ -296,3 +295,21 @@ Columns: * `completed`: Completed request. * **backends** (`text NOT NULL`): Comma-separated list of codegen backends to benchmark. If empty, the default set of codegen backends will be benchmarked. * **profiles** (`text NOT NULL`): Comma-separated list of profiles to benchmark. If empty, the default set of profiles will be benchmarked. + +### collector_config + +Information about the collector; it's target architecture, when it was added, +whether it is active and when it last had activity denoted by `last_heartbeat_at`. + +Columns: + +* **id** (`id`): A unique identifier for the collector. +* **target** (`text NOT NULL`): The ISA of the collector for example; `AArch64`. +* **name** (`text NOT NULL`): Unique name for the collector. +* **date_added** (`timestamptz NOT NULL`): When the collector was added +* **last_heartbeat_at** (`timestamptz`): When the collector last updated this + column, a way to test if the collector is still alive. +* **benchmark_set** (`int NOT NULL`): ID of the predefined benchmark suite to + execute. +* **is_active** (`boolean NOT NULL`): For controlling whether the collector is + active for use. Useful for adding/removing collectors. diff --git a/database/src/pool/postgres.rs b/database/src/pool/postgres.rs index b8079f5a7..9208f5e10 100644 --- a/database/src/pool/postgres.rs +++ b/database/src/pool/postgres.rs @@ -309,6 +309,22 @@ static MIGRATIONS: &[&str] = &[ // Prevent multiple try commits without a `sha` and the same `pr` number // being added to the table r#"CREATE UNIQUE INDEX benchmark_request_pr_commit_type_idx ON benchmark_request (pr, commit_type) WHERE status != 'completed';"#, + r#" + CREATE TABLE IF NOT EXISTS collector_config ( + id SERIAL PRIMARY KEY, + target TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, + date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL, + last_heartbeat_at TIMESTAMPTZ, + benchmark_set INTEGER NOT NULL, + is_active BOOLEAN DEFAULT FALSE NOT NULL, + + -- Given the current setup, we do not want 2 collectors that are active + -- with the same target using the same benchmark set. + CONSTRAINT collector_config_target_bench_active_uniq + UNIQUE (target, benchmark_set, is_active) + ); + "#, ]; #[async_trait::async_trait]