Group migrations
This commit is contained in:
parent
2714280567
commit
82e2385f59
12 changed files with 105 additions and 103 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"db_name": "SQLite",
|
"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": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"name": "name",
|
"name": "metric",
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
|
|
@ -40,5 +40,5 @@
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "b65eb154a77e79de390220d3675cc2b1ebe8cb706d2b0e1a0377c88fd6a175c2"
|
"hash": "0a4a3c4090e70ca643c4af0368ecf5c8dde66d898a900afa299a94e9a7bc62f8"
|
||||||
}
|
}
|
||||||
|
|
@ -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"
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"db_name": "SQLite",
|
"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": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -16,5 +16,5 @@
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "75264d014081dd190d880b89b415cecfd70dec9b56905027e27455c1dd4db02e"
|
"hash": "50ae538fd51000e8b4988981f66aed60bc30de2bb8cbb4a1533dfd551503b50a"
|
||||||
}
|
}
|
||||||
12
.sqlx/query-971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9.json
generated
Normal file
12
.sqlx/query-971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9.json
generated
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
@ -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);
|
|
||||||
|
|
@ -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;
|
|
||||||
|
|
@ -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);
|
|
||||||
76
migrations/20230815165523_init.sql
Normal file
76
migrations/20230815165523_init.sql
Normal file
|
|
@ -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);
|
||||||
|
|
@ -68,12 +68,12 @@ async fn save_work(
|
||||||
.execute(&mut *conn)
|
.execute(&mut *conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
for (name, measurement) in run.measurements {
|
for (metric, measurement) in run.measurements {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"\
|
"\
|
||||||
INSERT INTO run_measurements ( \
|
INSERT INTO run_measurements ( \
|
||||||
id, \
|
id, \
|
||||||
name, \
|
metric, \
|
||||||
value, \
|
value, \
|
||||||
stddev, \
|
stddev, \
|
||||||
unit, \
|
unit, \
|
||||||
|
|
@ -82,7 +82,7 @@ async fn save_work(
|
||||||
VALUES (?, ?, ?, ?, ?, ?) \
|
VALUES (?, ?, ?, ?, ?, ?) \
|
||||||
",
|
",
|
||||||
run.id,
|
run.id,
|
||||||
name,
|
metric,
|
||||||
measurement.value,
|
measurement.value,
|
||||||
measurement.stddev,
|
measurement.stddev,
|
||||||
measurement.unit,
|
measurement.unit,
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ pub async fn get_graph_data(
|
||||||
// The SQL queries that return one result per commit *must* return the same
|
// The SQL queries that return one result per commit *must* return the same
|
||||||
// amount of rows in the same order!
|
// 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!(
|
let unsorted_hashes = sqlx::query_scalar!(
|
||||||
"\
|
"\
|
||||||
SELECT hash FROM commits \
|
SELECT hash FROM commits \
|
||||||
|
|
@ -140,7 +143,7 @@ pub async fn get_graph_data(
|
||||||
SELECT hash, value, MAX(start) \
|
SELECT hash, value, MAX(start) \
|
||||||
FROM runs \
|
FROM runs \
|
||||||
JOIN run_measurements USING (id) \
|
JOIN run_measurements USING (id) \
|
||||||
WHERE name = ? \
|
WHERE metric = ? \
|
||||||
GROUP BY hash \
|
GROUP BY hash \
|
||||||
) \
|
) \
|
||||||
SELECT value \
|
SELECT value \
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Measurement {
|
struct Measurement {
|
||||||
name: String,
|
metric: String,
|
||||||
value: String,
|
value: String,
|
||||||
stddev: String,
|
stddev: String,
|
||||||
unit: String,
|
unit: String,
|
||||||
|
|
@ -81,20 +81,20 @@ async fn from_finished_run(
|
||||||
let measurements = sqlx::query!(
|
let measurements = sqlx::query!(
|
||||||
"\
|
"\
|
||||||
SELECT \
|
SELECT \
|
||||||
name, \
|
metric, \
|
||||||
value, \
|
value, \
|
||||||
stddev, \
|
stddev, \
|
||||||
unit, \
|
unit, \
|
||||||
direction \
|
direction \
|
||||||
FROM run_measurements \
|
FROM run_measurements \
|
||||||
WHERE id = ? \
|
WHERE id = ? \
|
||||||
ORDER BY name ASC \
|
ORDER BY metric ASC \
|
||||||
",
|
",
|
||||||
id,
|
id,
|
||||||
)
|
)
|
||||||
.fetch(db)
|
.fetch(db)
|
||||||
.map_ok(|r| Measurement {
|
.map_ok(|r| Measurement {
|
||||||
name: r.name,
|
metric: r.metric,
|
||||||
value: util::format_value(r.value),
|
value: util::format_value(r.value),
|
||||||
stddev: r.stddev.map(util::format_value).unwrap_or_default(),
|
stddev: r.stddev.map(util::format_value).unwrap_or_default(),
|
||||||
unit: r.unit.unwrap_or_default(),
|
unit: r.unit.unwrap_or_default(),
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for mm in measurements %}
|
{% for mm in measurements %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ mm.name }}</td>
|
<td>{{ mm.metric }}</td>
|
||||||
<td>{{ mm.value }}</td>
|
<td>{{ mm.value }}</td>
|
||||||
<td>{{ mm.stddev }}</td>
|
<td>{{ mm.stddev }}</td>
|
||||||
<td>{{ mm.unit }}</td>
|
<td>{{ mm.unit }}</td>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue