Skip to content

Commit 934ceb8

Browse files
committed
Rename benchmark DB functions to make it clear that they are working with compile-time benchmarks
1 parent da18499 commit 934ceb8

File tree

7 files changed

+48
-43
lines changed

7 files changed

+48
-43
lines changed

collector/src/bin/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn bench(
118118
}
119119
let mut tx = rt.block_on(conn.transaction());
120120
let (supports_stable, category) = category.db_representation();
121-
rt.block_on(tx.conn().record_benchmark(
121+
rt.block_on(tx.conn().record_compile_benchmark(
122122
&benchmark_name.0,
123123
Some(supports_stable),
124124
category,

database/src/bin/import-sqlite.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use database::{BenchmarkData, Lookup, Pool};
1+
use database::{CompileBenchmark, Lookup, Pool};
22
use hashbrown::HashMap;
33
use std::collections::HashSet;
44

@@ -25,7 +25,7 @@ async fn main() {
2525
let cid = postgres_conn.collection_id(&cid_name).await;
2626

2727
let mut benchmarks = HashSet::new();
28-
let benchmark_data: HashMap<String, BenchmarkData> = sqlite_conn
28+
let benchmark_data: HashMap<String, CompileBenchmark> = sqlite_conn
2929
.get_compile_benchmarks()
3030
.await
3131
.into_iter()
@@ -48,7 +48,7 @@ async fn main() {
4848
for &(benchmark, profile, scenario, metric) in sqlite_idx.all_statistic_descriptions() {
4949
if benchmarks.insert(benchmark) {
5050
postgres_conn
51-
.record_benchmark(
51+
.record_compile_benchmark(
5252
benchmark.as_str(),
5353
None,
5454
benchmark_data[benchmark.as_str()].category.clone(),

database/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ impl fmt::Display for CollectionId {
748748
}
749749

750750
#[derive(Debug, Clone, Serialize)]
751-
pub struct BenchmarkData {
751+
pub struct CompileBenchmark {
752752
pub name: String,
753753
pub category: String,
754754
}

database/src/pool.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{ArtifactId, ArtifactIdNumber, BenchmarkData};
1+
use crate::{ArtifactId, ArtifactIdNumber, CompileBenchmark};
22
use crate::{CollectionId, Index, Profile, QueuedCommit, Scenario, Step};
33
use chrono::{DateTime, Utc};
44
use hashbrown::HashMap;
@@ -15,7 +15,7 @@ pub trait Connection: Send + Sync {
1515
async fn transaction(&mut self) -> Box<dyn Transaction + '_>;
1616

1717
async fn load_index(&mut self) -> Index;
18-
async fn get_compile_benchmarks(&self) -> Vec<BenchmarkData>;
18+
async fn get_compile_benchmarks(&self) -> Vec<CompileBenchmark>;
1919

2020
async fn artifact_by_name(&self, artifact: &str) -> Option<ArtifactId>;
2121

@@ -27,7 +27,12 @@ pub trait Connection: Send + Sync {
2727
async fn artifact_id(&self, artifact: &ArtifactId) -> ArtifactIdNumber;
2828
/// None means that the caller doesn't know; it should be left alone if
2929
/// known or set to false if unknown.
30-
async fn record_benchmark(&self, krate: &str, supports_stable: Option<bool>, category: String);
30+
async fn record_compile_benchmark(
31+
&self,
32+
krate: &str,
33+
supports_stable: Option<bool>,
34+
category: String,
35+
);
3136
async fn record_statistic(
3237
&self,
3338
collection: CollectionId,

database/src/pool/postgres.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::pool::{Connection, ConnectionManager, ManagedConnection, Transaction};
22
use crate::{
3-
ArtifactId, ArtifactIdNumber, Benchmark, BenchmarkData, CollectionId, Commit, CommitType, Date,
4-
Index, Profile, QueuedCommit, Scenario,
3+
ArtifactId, ArtifactIdNumber, Benchmark, CollectionId, Commit, CommitType, CompileBenchmark,
4+
Date, Index, Profile, QueuedCommit, Scenario,
55
};
66
use anyhow::Context as _;
77
use chrono::{DateTime, TimeZone, Utc};
@@ -555,14 +555,14 @@ where
555555
.collect(),
556556
}
557557
}
558-
async fn get_compile_benchmarks(&self) -> Vec<BenchmarkData> {
558+
async fn get_compile_benchmarks(&self) -> Vec<CompileBenchmark> {
559559
let rows = self
560560
.conn()
561561
.query(&self.statements().get_benchmarks, &[])
562562
.await
563563
.unwrap();
564564
rows.into_iter()
565-
.map(|r| BenchmarkData {
565+
.map(|r| CompileBenchmark {
566566
name: r.get(0),
567567
category: r.get(1),
568568
})
@@ -883,7 +883,7 @@ where
883883
.unwrap();
884884
}
885885

886-
async fn record_benchmark(
886+
async fn record_compile_benchmark(
887887
&self,
888888
benchmark: &str,
889889
supports_stable: Option<bool>,

database/src/pool/sqlite.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::pool::{Connection, ConnectionManager, ManagedConnection, Transaction};
22
use crate::{
3-
ArtifactId, Benchmark, BenchmarkData, CollectionId, Commit, CommitType, Date, Profile,
3+
ArtifactId, Benchmark, CollectionId, Commit, CommitType, CompileBenchmark, Date, Profile,
44
};
55
use crate::{ArtifactIdNumber, Index, QueryDatum, QueuedCommit};
66
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
@@ -500,14 +500,38 @@ impl Connection for SqliteConnection {
500500
}
501501
}
502502

503-
async fn get_compile_benchmarks(&self) -> Vec<BenchmarkData> {
503+
async fn record_compile_benchmark(
504+
&self,
505+
benchmark: &str,
506+
supports_stable: Option<bool>,
507+
category: String,
508+
) {
509+
if let Some(stable) = supports_stable {
510+
self.raw_ref()
511+
.execute(
512+
"insert into benchmark (name, stabilized, category) VALUES (?, ?, ?)
513+
ON CONFLICT (name) do update set stabilized = excluded.stabilized, category = excluded.category",
514+
params![benchmark, stable, category],
515+
)
516+
.unwrap();
517+
} else {
518+
self.raw_ref()
519+
.execute(
520+
"insert into benchmark (name, stabilized, category) VALUES (?, ?, ?)
521+
ON CONFLICT (name) do update set category = excluded.category",
522+
params![benchmark, false, category],
523+
)
524+
.unwrap();
525+
}
526+
}
527+
async fn get_compile_benchmarks(&self) -> Vec<CompileBenchmark> {
504528
let conn = self.raw_ref();
505529
let mut query = conn
506530
.prepare_cached("select name, category from benchmark")
507531
.unwrap();
508532
let rows = query
509533
.query_map([], |row| {
510-
Ok(BenchmarkData {
534+
Ok(CompileBenchmark {
511535
name: row.get(0)?,
512536
category: row.get::<_, String>(1)?,
513537
})
@@ -821,30 +845,6 @@ impl Connection for SqliteConnection {
821845
)
822846
.unwrap();
823847
}
824-
async fn record_benchmark(
825-
&self,
826-
benchmark: &str,
827-
supports_stable: Option<bool>,
828-
category: String,
829-
) {
830-
if let Some(stable) = supports_stable {
831-
self.raw_ref()
832-
.execute(
833-
"insert into benchmark (name, stabilized, category) VALUES (?, ?, ?)
834-
ON CONFLICT (name) do update set stabilized = excluded.stabilized, category = excluded.category",
835-
params![benchmark, stable, category],
836-
)
837-
.unwrap();
838-
} else {
839-
self.raw_ref()
840-
.execute(
841-
"insert into benchmark (name, stabilized, category) VALUES (?, ?, ?)
842-
ON CONFLICT (name) do update set category = excluded.category",
843-
params![benchmark, false, category],
844-
)
845-
.unwrap();
846-
}
847-
}
848848
async fn collector_start(&self, aid: ArtifactIdNumber, steps: &[String]) {
849849
// Clean out any leftover unterminated steps.
850850
self.raw_ref()

site/src/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub mod bootstrap {
132132
pub mod comparison {
133133
use crate::comparison::Metric;
134134
use collector::Bound;
135-
use database::{BenchmarkData, Date};
135+
use database::{CompileBenchmark, Date};
136136
use serde::{Deserialize, Serialize};
137137
use std::collections::HashMap;
138138

@@ -149,8 +149,8 @@ pub mod comparison {
149149
pub category: String,
150150
}
151151

152-
impl From<BenchmarkData> for BenchmarkInfo {
153-
fn from(data: BenchmarkData) -> Self {
152+
impl From<CompileBenchmark> for BenchmarkInfo {
153+
fn from(data: CompileBenchmark) -> Self {
154154
Self {
155155
name: data.name,
156156
category: data.category.to_string(),

0 commit comments

Comments
 (0)