diff --git a/.sqlx/query-b65eb154a77e79de390220d3675cc2b1ebe8cb706d2b0e1a0377c88fd6a175c2.json b/.sqlx/query-0a4a3c4090e70ca643c4af0368ecf5c8dde66d898a900afa299a94e9a7bc62f8.json similarity index 74% rename from .sqlx/query-b65eb154a77e79de390220d3675cc2b1ebe8cb706d2b0e1a0377c88fd6a175c2.json rename to .sqlx/query-0a4a3c4090e70ca643c4af0368ecf5c8dde66d898a900afa299a94e9a7bc62f8.json index f3bbdc3..14ab8ed 100644 --- a/.sqlx/query-b65eb154a77e79de390220d3675cc2b1ebe8cb706d2b0e1a0377c88fd6a175c2.json +++ b/.sqlx/query-0a4a3c4090e70ca643c4af0368ecf5c8dde66d898a900afa299a94e9a7bc62f8.json @@ -1,10 +1,10 @@ { "db_name": "SQLite", - "query": "SELECT name, value, stddev, unit, direction FROM run_measurements WHERE id = ? ORDER BY name ASC ", + "query": "SELECT metric, value, stddev, unit, direction FROM run_measurements WHERE id = ? ORDER BY metric ASC ", "describe": { "columns": [ { - "name": "name", + "name": "metric", "ordinal": 0, "type_info": "Text" }, @@ -40,5 +40,5 @@ true ] }, - "hash": "b65eb154a77e79de390220d3675cc2b1ebe8cb706d2b0e1a0377c88fd6a175c2" + "hash": "0a4a3c4090e70ca643c4af0368ecf5c8dde66d898a900afa299a94e9a7bc62f8" } diff --git a/.sqlx/query-33cbc60a8d06adf3c3836d4193a80139615b69896a84dd1340759db6adbebf1f.json b/.sqlx/query-33cbc60a8d06adf3c3836d4193a80139615b69896a84dd1340759db6adbebf1f.json deleted file mode 100644 index 6b8df3f..0000000 --- a/.sqlx/query-33cbc60a8d06adf3c3836d4193a80139615b69896a84dd1340759db6adbebf1f.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO run_measurements ( id, name, value, stddev, unit, direction ) VALUES (?, ?, ?, ?, ?, ?) ", - "describe": { - "columns": [], - "parameters": { - "Right": 6 - }, - "nullable": [] - }, - "hash": "33cbc60a8d06adf3c3836d4193a80139615b69896a84dd1340759db6adbebf1f" -} diff --git a/.sqlx/query-75264d014081dd190d880b89b415cecfd70dec9b56905027e27455c1dd4db02e.json b/.sqlx/query-50ae538fd51000e8b4988981f66aed60bc30de2bb8cbb4a1533dfd551503b50a.json similarity index 51% rename from .sqlx/query-75264d014081dd190d880b89b415cecfd70dec9b56905027e27455c1dd4db02e.json rename to .sqlx/query-50ae538fd51000e8b4988981f66aed60bc30de2bb8cbb4a1533dfd551503b50a.json index e8a5f47..438b7dd 100644 --- a/.sqlx/query-75264d014081dd190d880b89b415cecfd70dec9b56905027e27455c1dd4db02e.json +++ b/.sqlx/query-50ae538fd51000e8b4988981f66aed60bc30de2bb8cbb4a1533dfd551503b50a.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "WITH measurements AS ( SELECT hash, value, MAX(start) FROM runs JOIN run_measurements USING (id) WHERE name = ? GROUP BY hash ) SELECT value FROM commits LEFT JOIN measurements USING (hash) WHERE reachable = 2 ORDER BY unixepoch(committer_date) ASC, hash ASC ", + "query": "WITH measurements AS ( SELECT hash, value, MAX(start) FROM runs JOIN run_measurements USING (id) WHERE metric = ? GROUP BY hash ) SELECT value FROM commits LEFT JOIN measurements USING (hash) WHERE reachable = 2 ORDER BY unixepoch(committer_date) ASC, hash ASC ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ true ] }, - "hash": "75264d014081dd190d880b89b415cecfd70dec9b56905027e27455c1dd4db02e" + "hash": "50ae538fd51000e8b4988981f66aed60bc30de2bb8cbb4a1533dfd551503b50a" } diff --git a/.sqlx/query-971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9.json b/.sqlx/query-971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9.json new file mode 100644 index 0000000..fb926a0 --- /dev/null +++ b/.sqlx/query-971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT INTO run_measurements ( id, metric, value, stddev, unit, direction ) VALUES (?, ?, ?, ?, ?, ?) ", + "describe": { + "columns": [], + "parameters": { + "Right": 6 + }, + "nullable": [] + }, + "hash": "971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9" +} diff --git a/migrations/20230805101911_commits.sql b/migrations/20230805101911_commits.sql deleted file mode 100644 index 71c3f50..0000000 --- a/migrations/20230805101911_commits.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE commits ( - hash TEXT NOT NULL PRIMARY KEY, - author TEXT NOT NULL, - author_date TEXT NOT NULL, - committer TEXT NOT NULL, - committer_date TEXT NOT NULL, - message TEXT NOT NULL, - reachable INT NOT NULL DEFAULT 0, - new INT NOT NULL DEFAULT 1 -) STRICT; - -CREATE TABLE commit_links ( - child TEXT NOT NULL, - parent TEXT NOT NULL, - - PRIMARY KEY (parent, child), - FOREIGN KEY (parent) REFERENCES commits (hash) ON DELETE CASCADE, - FOREIGN KEY (child) REFERENCES commits (hash) ON DELETE CASCADE -) STRICT; - -CREATE TABLE refs ( - name TEXT NOT NULL PRIMARY KEY, - hash TEXT NOT NULL, - tracked INT NOT NULL DEFAULT 0, - - FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE -) STRICT; - -CREATE INDEX idx_commits_committer_date_hash -ON commits (unixepoch(committer_date), hash); - -CREATE INDEX idx_commit_links_parent_child -ON commit_links (parent, child); diff --git a/migrations/20230806143356_queue.sql b/migrations/20230806143356_queue.sql deleted file mode 100644 index 5649450..0000000 --- a/migrations/20230806143356_queue.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE queue ( - hash TEXT NOT NULL PRIMARY KEY, - date TEXT NOT NULL, - priority INT NOT NULL DEFAULT 0, - - FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE -) STRICT; diff --git a/migrations/20230809141314_runs.sql b/migrations/20230809141314_runs.sql deleted file mode 100644 index 652dcea..0000000 --- a/migrations/20230809141314_runs.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE runs ( - id TEXT NOT NULL PRIMARY KEY, - hash TEXT NOT NULL, - bench_method TEXT NOT NULL, - worker_name TEXT NOT NULL, - worker_info TEXT, - start TEXT NOT NULL, - end TEXT NOT NULL, - exit_code INT NOT NULL, - - FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE -) STRICT; - -CREATE TABLE run_measurements ( - id TEXT NOT NULL, - name TEXT NOT NULL, - value REAL NOT NULL, - stddev REAL, - unit TEXT, - direction INT, - - PRIMARY KEY (id, name), - FOREIGN KEY (id) REFERENCES runs (id) ON DELETE CASCADE -) STRICT; - -CREATE TABLE run_output ( - id TEXT NOT NULL, - idx INT NOT NULL, - source INT NOT NULL, - text TEXT NOT NULL, - - PRIMARY KEY (id, idx), - FOREIGN KEY (id) REFERENCES runs (id) ON DELETE CASCADE -) STRICT; - -CREATE INDEX idx_run_measurements_name_id_value -ON run_measurements (name, id, value); diff --git a/migrations/20230815165523_init.sql b/migrations/20230815165523_init.sql new file mode 100644 index 0000000..88e16a0 --- /dev/null +++ b/migrations/20230815165523_init.sql @@ -0,0 +1,76 @@ +CREATE TABLE commits ( + hash TEXT NOT NULL PRIMARY KEY, + author TEXT NOT NULL, + author_date TEXT NOT NULL, + committer TEXT NOT NULL, + committer_date TEXT NOT NULL, + message TEXT NOT NULL, + reachable INT NOT NULL DEFAULT 0, + new INT NOT NULL DEFAULT 1 +) STRICT; + +CREATE TABLE commit_links ( + child TEXT NOT NULL, + parent TEXT NOT NULL, + + PRIMARY KEY (parent, child), + FOREIGN KEY (parent) REFERENCES commits (hash) ON DELETE CASCADE, + FOREIGN KEY (child) REFERENCES commits (hash) ON DELETE CASCADE +) STRICT; + +CREATE TABLE refs ( + name TEXT NOT NULL PRIMARY KEY, + hash TEXT NOT NULL, + tracked INT NOT NULL DEFAULT 0, + + FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE +) STRICT; + +CREATE TABLE runs ( + id TEXT NOT NULL PRIMARY KEY, + hash TEXT NOT NULL, + bench_method TEXT NOT NULL, + worker_name TEXT NOT NULL, + worker_info TEXT, + start TEXT NOT NULL, + end TEXT NOT NULL, + exit_code INT NOT NULL, + + FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE +) STRICT; + +CREATE TABLE run_measurements ( + id TEXT NOT NULL, + metric TEXT NOT NULL, + value REAL NOT NULL, + stddev REAL, + unit TEXT, + direction INT, + + PRIMARY KEY (id, metric), + FOREIGN KEY (id) REFERENCES runs (id) ON DELETE CASCADE +) STRICT; + +CREATE TABLE run_output ( + id TEXT NOT NULL, + idx INT NOT NULL, + source INT NOT NULL, + text TEXT NOT NULL, + + PRIMARY KEY (id, idx), + FOREIGN KEY (id) REFERENCES runs (id) ON DELETE CASCADE +) STRICT; + +CREATE TABLE queue ( + hash TEXT NOT NULL PRIMARY KEY, + date TEXT NOT NULL, + priority INT NOT NULL DEFAULT 0, + + FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE +) STRICT; + +CREATE INDEX idx_commit_links_parent_child +ON commit_links (parent, child); + +CREATE INDEX idx_run_measurements_metric_id_value +ON run_measurements (metric, id, value); diff --git a/src/server/web/api/worker.rs b/src/server/web/api/worker.rs index b85a155..e99fc47 100644 --- a/src/server/web/api/worker.rs +++ b/src/server/web/api/worker.rs @@ -68,12 +68,12 @@ async fn save_work( .execute(&mut *conn) .await?; - for (name, measurement) in run.measurements { + for (metric, measurement) in run.measurements { sqlx::query!( "\ INSERT INTO run_measurements ( \ id, \ - name, \ + metric, \ value, \ stddev, \ unit, \ @@ -82,7 +82,7 @@ async fn save_work( VALUES (?, ?, ?, ?, ?, ?) \ ", run.id, - name, + metric, measurement.value, measurement.stddev, measurement.unit, diff --git a/src/server/web/pages/graph.rs b/src/server/web/pages/graph.rs index ddc2fa7..2ee99e3 100644 --- a/src/server/web/pages/graph.rs +++ b/src/server/web/pages/graph.rs @@ -67,6 +67,9 @@ pub async fn get_graph_data( // The SQL queries that return one result per commit *must* return the same // amount of rows in the same order! + // TODO Order queries by hash only + // TODO After topo sort, do a stable sort by committer date + let unsorted_hashes = sqlx::query_scalar!( "\ SELECT hash FROM commits \ @@ -140,7 +143,7 @@ pub async fn get_graph_data( SELECT hash, value, MAX(start) \ FROM runs \ JOIN run_measurements USING (id) \ - WHERE name = ? \ + WHERE metric = ? \ GROUP BY hash \ ) \ SELECT value \ diff --git a/src/server/web/pages/run.rs b/src/server/web/pages/run.rs index 8241a91..d4c967a 100644 --- a/src/server/web/pages/run.rs +++ b/src/server/web/pages/run.rs @@ -21,7 +21,7 @@ use crate::{ }; struct Measurement { - name: String, + metric: String, value: String, stddev: String, unit: String, @@ -81,20 +81,20 @@ async fn from_finished_run( let measurements = sqlx::query!( "\ SELECT \ - name, \ + metric, \ value, \ stddev, \ unit, \ direction \ FROM run_measurements \ WHERE id = ? \ - ORDER BY name ASC \ + ORDER BY metric ASC \ ", id, ) .fetch(db) .map_ok(|r| Measurement { - name: r.name, + metric: r.metric, value: util::format_value(r.value), stddev: r.stddev.map(util::format_value).unwrap_or_default(), unit: r.unit.unwrap_or_default(), diff --git a/templates/pages/run_finished.html b/templates/pages/run_finished.html index 0f9a310..302ca99 100644 --- a/templates/pages/run_finished.html +++ b/templates/pages/run_finished.html @@ -44,7 +44,7 @@
{% for mm in measurements %}