Skip to content

Commit e5196b3

Browse files
Merge pull request #1748 from Kobzol/remove-self-profile-queries
Remove storage of self profile data into the database
2 parents 45e0afe + 0b3051b commit e5196b3

File tree

8 files changed

+10
-354
lines changed

8 files changed

+10
-354
lines changed

collector/src/compile/execute/bencher.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,6 @@ impl<'a> BenchProcessor<'a> {
134134
));
135135
}
136136

137-
if let Some(sp) = &stats.1 {
138-
let conn = &*self.conn;
139-
let artifact_row_id = self.artifact_row_id;
140-
let benchmark = self.benchmark.0.as_str();
141-
for qd in &sp.query_data {
142-
buf.push(conn.record_self_profile_query(
143-
collection,
144-
artifact_row_id,
145-
benchmark,
146-
profile,
147-
scenario,
148-
qd.label.as_str(),
149-
database::QueryDatum {
150-
self_time: qd.self_time,
151-
blocked_time: qd.blocked_time,
152-
incremental_load_time: qd.incremental_load_time,
153-
number_of_cache_hits: qd.number_of_cache_hits,
154-
invocation_count: qd.invocation_count,
155-
},
156-
));
157-
}
158-
}
159-
160137
while let Some(()) = buf.next().await {}
161138
}
162139

database/schema.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Below is an explanation of the current database schema. This schema is duplicate
44

55
## Overview
66

7-
In general, the database is used to track three groups of things:
7+
In general, the database is used to track four groups of things:
88
* Performance run statistics (e.g., instruction count) for compile time benchmarks on a per benchmark, profile, and scenario basis.
99
* Performance run statistics (e.g., instruction count) for runtime benchmarks on a per benchmark basis.
1010
* Self profile data gathered with `-Zself-profile`.
@@ -210,31 +210,6 @@ series aid cid value
210210
1 1 1 24.93
211211
```
212212

213-
### self_profile_query_series
214-
215-
Describes a parametrization of a self-profile query. Contains a unique combination
216-
of a benchmark, profile, scenario and a `rustc` self-profile query.
217-
218-
This table exists to avoid duplicating benchmarks, profiles, scenarios etc. many times in the `self_profile_query` table.
219-
220-
```
221-
sqlite> select * from runtime_pstat limit 1;
222-
id crate profile cache query
223-
-- ----- ------- ---------- -----
224-
1 hello-world debug full hir_crate
225-
```
226-
227-
### self_profile_query
228-
229-
A measured value of a single `rustc` self-profile query that is unique to a `self_profile_query_series`, `artifact` and a `collection`.
230-
231-
```
232-
sqlite> select * from runtime_pstat limit 1;
233-
series aid cid self_time blocked_time incremental_load_time number_of_cache_hits invocation_count
234-
-- ----- --- --------- ------------ --------------------- -------------------- ----------------
235-
1 42 58 11.8 10.2 8.4 224 408
236-
```
237-
238213
### rustc_compilation
239214

240215
Records the duration of compiling a `rustc` crate for a given artifact and collection.

database/src/bin/postgres-to-sqlite.rs

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -357,66 +357,6 @@ impl Table for RustcCompilation {
357357
}
358358
}
359359

360-
struct SelfProfileQuery;
361-
362-
impl Table for SelfProfileQuery {
363-
fn name(&self) -> &'static str {
364-
"self_profile_query"
365-
}
366-
367-
fn postgres_select_statement(&self, since_weeks_ago: Option<u32>) -> String {
368-
let s = "select series, aid, cid, self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count from ".to_string() + self.name();
369-
with_filter_clause_maybe(s, ARTIFACT_JOIN_AND_WHERE, since_weeks_ago)
370-
}
371-
372-
fn sqlite_insert_statement(&self) -> &'static str {
373-
"insert into self_profile_query (series, aid, cid, self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
374-
}
375-
376-
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
377-
statement
378-
.execute(params![
379-
row.get::<_, i32>(0),
380-
row.get::<_, i32>(1),
381-
row.get::<_, i32>(2),
382-
row.get::<_, Option<i64>>(3),
383-
row.get::<_, Option<i64>>(4),
384-
row.get::<_, Option<i64>>(5),
385-
row.get::<_, Option<i32>>(6),
386-
row.get::<_, Option<i32>>(7),
387-
])
388-
.unwrap();
389-
}
390-
}
391-
392-
struct SelfProfileQuerySeries;
393-
394-
impl Table for SelfProfileQuerySeries {
395-
fn name(&self) -> &'static str {
396-
"self_profile_query_series"
397-
}
398-
399-
fn postgres_select_statement(&self, _since_weeks_ago: Option<u32>) -> String {
400-
"select id, crate, profile, cache, query from ".to_string() + self.name()
401-
}
402-
403-
fn sqlite_insert_statement(&self) -> &'static str {
404-
"insert into self_profile_query_series (id, crate, profile, cache, query) VALUES (?, ?, ?, ?, ?)"
405-
}
406-
407-
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
408-
statement
409-
.execute(params![
410-
row.get::<_, i32>(0),
411-
row.get::<_, &str>(1),
412-
row.get::<_, &str>(2),
413-
row.get::<_, &str>(3),
414-
row.get::<_, &str>(4),
415-
])
416-
.unwrap();
417-
}
418-
}
419-
420360
#[tokio::main]
421361
async fn main() -> anyhow::Result<()> {
422362
env_logger::init();
@@ -434,8 +374,6 @@ async fn main() -> anyhow::Result<()> {
434374
&PullRequestBuild,
435375
&RawSelfProfile,
436376
&RustcCompilation,
437-
&SelfProfileQuerySeries,
438-
&SelfProfileQuery,
439377
];
440378

441379
let table_names: Vec<_> = tables.iter().map(|table| table.name()).collect();
@@ -494,18 +432,12 @@ async fn main() -> anyhow::Result<()> {
494432
let postgres = matches.get_one::<String>("postgres-db").unwrap();
495433
let sqlite = matches.get_one::<String>("sqlite-db").unwrap();
496434

497-
let mut exclude_tables: std::collections::HashSet<_> = matches
435+
let exclude_tables: std::collections::HashSet<_> = matches
498436
.get_many::<String>("exclude-tables")
499437
.unwrap_or_default()
500438
.cloned()
501439
.collect();
502440

503-
if matches.get_flag("no-self-profile") {
504-
exclude_tables.insert(SelfProfileQuerySeries.name().to_owned());
505-
exclude_tables.insert(SelfProfileQuery.name().to_owned());
506-
// `RawSelfProfile` is intentionally kept.
507-
}
508-
509441
let since_weeks_ago = matches.get_one::<u32>("since-weeks-ago").copied();
510442

511443
let mut postgres: tokio_postgres::Client =

database/src/bin/sqlite-to-postgres.rs

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -438,86 +438,6 @@ impl Table for RustcCompilation {
438438
}
439439
}
440440

441-
struct SelfProfileQuery;
442-
443-
#[derive(Serialize)]
444-
struct SelfProfileQueryRow {
445-
series: i32,
446-
aid: i32,
447-
cid: i32,
448-
self_time: Nullable<i64>,
449-
blocked_time: Nullable<i64>,
450-
incremental_load_time: Nullable<i64>,
451-
number_of_cache_hits: Nullable<i32>,
452-
invocation_count: Nullable<i32>,
453-
}
454-
455-
impl Table for SelfProfileQuery {
456-
fn name() -> &'static str {
457-
"self_profile_query"
458-
}
459-
460-
fn sqlite_attributes() -> &'static str {
461-
"series, aid, cid, self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count"
462-
}
463-
464-
fn postgres_generated_id_attribute() -> Option<&'static str> {
465-
None
466-
}
467-
468-
fn write_postgres_csv_row<W: Write>(writer: &mut csv::Writer<W>, row: &rusqlite::Row) {
469-
writer
470-
.serialize(SelfProfileQueryRow {
471-
series: row.get(0).unwrap(),
472-
aid: row.get(1).unwrap(),
473-
cid: row.get(2).unwrap(),
474-
self_time: row.get(3).unwrap(),
475-
blocked_time: row.get(4).unwrap(),
476-
incremental_load_time: row.get(5).unwrap(),
477-
number_of_cache_hits: row.get(6).unwrap(),
478-
invocation_count: row.get(7).unwrap(),
479-
})
480-
.unwrap();
481-
}
482-
}
483-
484-
struct SelfProfileQuerySeries;
485-
486-
#[derive(Serialize)]
487-
struct SelfProfileQuerySeriesRow<'a> {
488-
id: i32,
489-
krate: &'a str,
490-
profile: &'a str,
491-
cache: &'a str,
492-
query: &'a str,
493-
}
494-
495-
impl Table for SelfProfileQuerySeries {
496-
fn name() -> &'static str {
497-
"self_profile_query_series"
498-
}
499-
500-
fn sqlite_attributes() -> &'static str {
501-
"id, crate, profile, cache, query"
502-
}
503-
504-
fn postgres_generated_id_attribute() -> Option<&'static str> {
505-
Some("id")
506-
}
507-
508-
fn write_postgres_csv_row<W: Write>(writer: &mut csv::Writer<W>, row: &rusqlite::Row) {
509-
writer
510-
.serialize(SelfProfileQuerySeriesRow {
511-
id: row.get(0).unwrap(),
512-
krate: row.get_ref(1).unwrap().as_str().unwrap(),
513-
profile: row.get_ref(2).unwrap().as_str().unwrap(),
514-
cache: row.get_ref(3).unwrap().as_str().unwrap(),
515-
query: row.get_ref(4).unwrap().as_str().unwrap(),
516-
})
517-
.unwrap();
518-
}
519-
}
520-
521441
// `Nullable<T>` helps to work around the fact that the `csv` crate (and the CSV
522442
// format in general) doesn't distinguish between nulls and empty strings, while
523443
// the Postgres CSV format does.
@@ -639,8 +559,6 @@ async fn main() -> anyhow::Result<()> {
639559
copy::<PullRequestBuild>(&sqlite_tx, &postgres_tx).await;
640560
copy::<RawSelfProfile>(&sqlite_tx, &postgres_tx).await;
641561
copy::<RustcCompilation>(&sqlite_tx, &postgres_tx).await;
642-
copy::<SelfProfileQuerySeries>(&sqlite_tx, &postgres_tx).await;
643-
copy::<SelfProfileQuery>(&sqlite_tx, &postgres_tx).await;
644562

645563
// This is overly paranoid, but don't commit the Postgres transaction until
646564
// the rollback of the SQLite transaction succeeds.

database/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,6 @@ impl ArtifactId {
410410

411411
intern!(pub struct QueryLabel);
412412

413-
#[derive(PartialEq, Eq, Clone, Debug)]
414-
pub struct QueryDatum {
415-
pub self_time: Duration,
416-
pub blocked_time: Duration,
417-
pub incremental_load_time: Duration,
418-
pub number_of_cache_hits: u32,
419-
pub invocation_count: u32,
420-
}
421-
422413
/// A database row ID for an artifact in the artifact table
423414
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
424415
pub struct ArtifactIdNumber(pub u32);

database/src/pool.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,6 @@ pub trait Connection: Send + Sync {
6767
profile: Profile,
6868
scenario: Scenario,
6969
);
70-
#[allow(clippy::too_many_arguments)]
71-
async fn record_self_profile_query(
72-
&self,
73-
collection: CollectionId,
74-
artifact: ArtifactIdNumber,
75-
benchmark: &str,
76-
profile: Profile,
77-
scenario: Scenario,
78-
query: &str,
79-
qd: crate::QueryDatum,
80-
);
8170
async fn record_error(&self, artifact: ArtifactIdNumber, krate: &str, error: &str);
8271
async fn record_rustc_crate(
8372
&self,

0 commit comments

Comments
 (0)