Skip to content

Commit ddb33b1

Browse files
committed
Remove a bunch of code
1 parent 07df23e commit ddb33b1

File tree

5 files changed

+2
-411
lines changed

5 files changed

+2
-411
lines changed

database/src/lib.rs

-54
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,6 @@ pub struct QueryDatum {
448448
pub invocation_count: u32,
449449
}
450450

451-
#[async_trait::async_trait]
452-
impl SeriesType for QueryDatum {
453-
async fn get(
454-
conn: &dyn pool::Connection,
455-
series: u32,
456-
artifact_row_id: ArtifactIdNumber,
457-
) -> Option<Self> {
458-
conn.get_self_profile_query(series, artifact_row_id).await
459-
}
460-
}
461451
#[derive(Hash, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
462452
pub struct LabelId(pub u8, pub u32);
463453

@@ -481,8 +471,6 @@ pub struct Index {
481471
/// Id lookup of stat description ids
482472
/// For legacy reasons called `pstat_series` in the database, and so the name is kept here.
483473
pstat_series: Indexed<(Benchmark, Profile, Scenario, Metric)>,
484-
/// Id lookup of a given process query label
485-
queries: Indexed<(Benchmark, Profile, Scenario, QueryLabel)>,
486474
}
487475

488476
/// An index lookup
@@ -605,12 +593,6 @@ pub enum DbLabel {
605593
scenario: Scenario,
606594
metric: Metric,
607595
},
608-
SelfProfileQuery {
609-
benchmark: Benchmark,
610-
profile: Profile,
611-
scenario: Scenario,
612-
query: QueryLabel,
613-
},
614596
}
615597

616598
pub trait Lookup {
@@ -631,14 +613,6 @@ impl Lookup for DbLabel {
631613
} => index
632614
.pstat_series
633615
.get(&(*benchmark, *profile, *scenario, *metric)),
634-
DbLabel::SelfProfileQuery {
635-
benchmark,
636-
profile,
637-
scenario,
638-
query,
639-
} => index
640-
.queries
641-
.get(&(*benchmark, *profile, *scenario, *query)),
642616
}
643617
}
644618
}
@@ -716,34 +690,6 @@ impl Index {
716690
) -> impl Iterator<Item = &'_ (Benchmark, Profile, Scenario, Metric)> + '_ {
717691
self.pstat_series.map.keys()
718692
}
719-
720-
// FIXME: in theory this won't scale indefinitely as there's potentially
721-
// millions of queries and labels and iterating all of them is eventually
722-
// going to be impractical. But for now it performs quite well, so we'll go
723-
// for it as keeping indices around would be annoying.
724-
pub fn all_query_series(
725-
&self,
726-
) -> impl Iterator<Item = &'_ (Benchmark, Profile, Scenario, QueryLabel)> + '_ {
727-
self.queries.map.keys()
728-
}
729-
730-
// FIXME: in theory this won't scale indefinitely as there's potentially
731-
// millions of queries and labels and iterating all of them is eventually
732-
// going to be impractical. But for now it performs quite well, so we'll go
733-
// for it as keeping indices around would be annoying.
734-
pub fn filtered_queries(
735-
&self,
736-
benchmark: Benchmark,
737-
profile: Profile,
738-
scenario: Scenario,
739-
) -> impl Iterator<Item = QueryLabel> + '_ {
740-
self.queries
741-
.map
742-
.keys()
743-
.filter(move |&&(b, p, s, _)| b == benchmark && p == profile && s == scenario)
744-
.map(|&(_, _, _, q)| q)
745-
.filter(|q| !q.as_str().starts_with("codegen passes ["))
746-
}
747693
}
748694

749695
#[derive(Debug)]

database/src/pool.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{ArtifactId, ArtifactIdNumber, BenchmarkData};
2-
use crate::{CollectionId, Index, Profile, QueryDatum, QueuedCommit, Scenario, Step};
2+
use crate::{CollectionId, Index, Profile, QueuedCommit, Scenario, Step};
33
use chrono::{DateTime, Utc};
44
use hashbrown::HashMap;
55
use std::sync::{Arc, Mutex};
@@ -58,7 +58,7 @@ pub trait Connection: Send + Sync {
5858
profile: Profile,
5959
scenario: Scenario,
6060
query: &str,
61-
qd: QueryDatum,
61+
qd: crate::QueryDatum,
6262
);
6363
async fn record_error(&self, artifact: ArtifactIdNumber, krate: &str, error: &str);
6464
async fn record_rustc_crate(
@@ -92,18 +92,6 @@ pub trait Connection: Send + Sync {
9292
pstat_series_row_ids: &[u32],
9393
artifact_row_id: &[Option<ArtifactIdNumber>],
9494
) -> Vec<Vec<Option<f64>>>;
95-
async fn get_self_profile(
96-
&self,
97-
artifact_row_id: ArtifactIdNumber,
98-
crate_: &str,
99-
profile: &str,
100-
cache: &str,
101-
) -> HashMap<crate::QueryLabel, QueryDatum>;
102-
async fn get_self_profile_query(
103-
&self,
104-
series: u32,
105-
artifact_row_id: ArtifactIdNumber,
106-
) -> Option<QueryDatum>;
10795
async fn get_error(&self, artifact_row_id: ArtifactIdNumber) -> HashMap<String, String>;
10896

10997
async fn queue_pr(

database/src/pool/postgres.rs

-108
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ pub struct CachedStatements {
276276
get_rustc_compilation_by_crate: Statement,
277277
insert_pstat: Statement,
278278
insert_rustc: Statement,
279-
get_self_profile_query: Statement,
280-
get_self_profile: Statement,
281279
insert_self_profile_query: Statement,
282280
select_self_query_series: Statement,
283281
insert_self_query_series: Statement,
@@ -393,27 +391,6 @@ impl PostgresConnection {
393391
.prepare("insert into rustc_compilation (aid, cid, crate, duration) VALUES ($1, $2, $3, $4)")
394392
.await
395393
.unwrap(),
396-
get_self_profile_query: conn
397-
.prepare(
398-
"select
399-
self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count
400-
from self_profile_query
401-
where series = $1 and aid = $2 order by self_time asc;
402-
",
403-
)
404-
.await
405-
.unwrap(),
406-
get_self_profile: conn.prepare("
407-
select
408-
query, self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count
409-
from self_profile_query_series
410-
join self_profile_query on self_profile_query_series.id = self_profile_query.series
411-
where
412-
crate = $1
413-
and profile = $2
414-
and cache = $3
415-
and aid = $4
416-
").await.unwrap(),
417394
insert_self_profile_query: conn
418395
.prepare(
419396
"insert into self_profile_query(
@@ -577,33 +554,6 @@ where
577554
)
578555
})
579556
.collect(),
580-
queries: self
581-
.conn()
582-
.query(
583-
"select id, crate, profile, cache, query from self_profile_query_series;",
584-
&[],
585-
)
586-
.await
587-
.unwrap()
588-
.into_iter()
589-
.map(|row| {
590-
(
591-
row.get::<_, i32>(0) as u32,
592-
(
593-
Benchmark::from(row.get::<_, String>(1).as_str()),
594-
match row.get::<_, String>(2).as_str() {
595-
"check" => Profile::Check,
596-
"opt" => Profile::Opt,
597-
"debug" => Profile::Debug,
598-
"doc" => Profile::Doc,
599-
o => unreachable!("{}: not a profile", o),
600-
},
601-
row.get::<_, String>(3).as_str().parse().unwrap(),
602-
row.get::<_, String>(4).as_str().into(),
603-
),
604-
)
605-
})
606-
.collect(),
607557
}
608558
}
609559
async fn get_benchmarks(&self) -> Vec<BenchmarkData> {
@@ -645,64 +595,6 @@ where
645595
.map(|row| row.get::<_, Vec<Option<f64>>>(0))
646596
.collect()
647597
}
648-
async fn get_self_profile_query(
649-
&self,
650-
pstat_series_row_id: u32,
651-
artifact_row_id: crate::ArtifactIdNumber,
652-
) -> Option<crate::QueryDatum> {
653-
let row = self
654-
.conn()
655-
.query_opt(
656-
&self.statements().get_self_profile_query,
657-
&[&(pstat_series_row_id as i32), &(artifact_row_id.0 as i32)],
658-
)
659-
.await
660-
.unwrap()?;
661-
let self_time: i64 = row.get(0);
662-
let blocked_time: i64 = row.get(1);
663-
let incremental_load_time: i64 = row.get(2);
664-
Some(crate::QueryDatum {
665-
self_time: Duration::from_nanos(self_time as u64),
666-
blocked_time: Duration::from_nanos(blocked_time as u64),
667-
incremental_load_time: Duration::from_nanos(incremental_load_time as u64),
668-
number_of_cache_hits: row.get::<_, i32>(3) as u32,
669-
invocation_count: row.get::<_, i32>(4) as u32,
670-
})
671-
}
672-
async fn get_self_profile(
673-
&self,
674-
artifact_row_id: ArtifactIdNumber,
675-
crate_: &str,
676-
profile: &str,
677-
scenario: &str,
678-
) -> HashMap<crate::QueryLabel, crate::QueryDatum> {
679-
let rows = self
680-
.conn()
681-
.query(
682-
&self.statements().get_self_profile,
683-
&[&crate_, &profile, &scenario, &(artifact_row_id.0 as i32)],
684-
)
685-
.await
686-
.unwrap();
687-
688-
rows.into_iter()
689-
.map(|r| {
690-
let self_time: i64 = r.get(1);
691-
let blocked_time: i64 = r.get(2);
692-
let incremental_load_time: i64 = r.get(3);
693-
(
694-
r.get::<_, &str>(0).into(),
695-
crate::QueryDatum {
696-
self_time: Duration::from_nanos(self_time as u64),
697-
blocked_time: Duration::from_nanos(blocked_time as u64),
698-
incremental_load_time: Duration::from_nanos(incremental_load_time as u64),
699-
number_of_cache_hits: r.get::<_, i32>(4) as u32,
700-
invocation_count: r.get::<_, i32>(5) as u32,
701-
},
702-
)
703-
})
704-
.collect()
705-
}
706598
async fn get_error(&self, artifact_row_id: crate::ArtifactIdNumber) -> HashMap<String, String> {
707599
let rows = self
708600
.conn()

database/src/pool/sqlite.rs

-89
Original file line numberDiff line numberDiff line change
@@ -435,30 +435,6 @@ impl Connection for SqliteConnection {
435435
.unwrap()
436436
.map(|r| r.unwrap())
437437
.collect();
438-
let queries = self
439-
.raw()
440-
.prepare("select id, crate, profile, cache, query from self_profile_query_series;")
441-
.unwrap()
442-
.query_map(params![], |row| {
443-
Ok((
444-
row.get::<_, i32>(0)? as u32,
445-
(
446-
Benchmark::from(row.get::<_, String>(1)?.as_str()),
447-
match row.get::<_, String>(2)?.as_str() {
448-
"check" => Profile::Check,
449-
"opt" => Profile::Opt,
450-
"debug" => Profile::Debug,
451-
"doc" => Profile::Doc,
452-
o => unreachable!("{}: not a profile", o),
453-
},
454-
row.get::<_, String>(3)?.as_str().parse().unwrap(),
455-
row.get::<_, String>(4)?.as_str().into(),
456-
),
457-
))
458-
})
459-
.unwrap()
460-
.map(|r| r.unwrap())
461-
.collect();
462438
let errors = self
463439
.raw()
464440
.prepare("select id, crate from error_series")
@@ -500,7 +476,6 @@ impl Connection for SqliteConnection {
500476
.unwrap()
501477
.map(|r| r.unwrap())
502478
.collect(),
503-
queries,
504479
}
505480
}
506481

@@ -556,70 +531,6 @@ impl Connection for SqliteConnection {
556531
})
557532
.collect()
558533
}
559-
async fn get_self_profile_query(
560-
&self,
561-
series: u32,
562-
aid: ArtifactIdNumber,
563-
) -> Option<QueryDatum> {
564-
self.raw_ref().prepare_cached("
565-
select self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count
566-
from self_profile_query
567-
where series = ? and aid = ? order by self_time asc;").unwrap()
568-
.query_row(params![&series, &aid.0], |row| {
569-
let self_time: i64 = row.get(0)?;
570-
let blocked_time: i64 = row.get(1)?;
571-
let incremental_load_time: i64 = row.get(2)?;
572-
Ok(QueryDatum {
573-
self_time: Duration::from_nanos(self_time as u64),
574-
blocked_time: Duration::from_nanos(blocked_time as u64),
575-
incremental_load_time: Duration::from_nanos(incremental_load_time as u64),
576-
number_of_cache_hits: row.get(3)?,
577-
invocation_count: row.get(4)?,
578-
})
579-
580-
})
581-
.optional()
582-
.unwrap()
583-
}
584-
async fn get_self_profile(
585-
&self,
586-
aid: ArtifactIdNumber,
587-
crate_: &str,
588-
profile: &str,
589-
scenario: &str,
590-
) -> HashMap<crate::QueryLabel, crate::QueryDatum> {
591-
self.raw_ref()
592-
.prepare_cached("
593-
select
594-
query, self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count
595-
from self_profile_query_series
596-
join self_profile_query on self_profile_query_series.id = self_profile_query.series
597-
where
598-
crate = ?
599-
and profile = ?
600-
and cache = ?
601-
and aid = ?
602-
")
603-
.unwrap()
604-
.query_map(params![&crate_, &profile, &scenario, &aid.0], |r| {
605-
let self_time: i64 = r.get(1)?;
606-
let blocked_time: i64 = r.get(2)?;
607-
let incremental_load_time: i64 = r.get(3)?;
608-
Ok((
609-
r.get::<_, String>(0)?.as_str().into(),
610-
crate::QueryDatum {
611-
self_time: Duration::from_nanos(self_time as u64),
612-
blocked_time: Duration::from_nanos(blocked_time as u64),
613-
incremental_load_time: Duration::from_nanos(incremental_load_time as u64),
614-
number_of_cache_hits: r.get::<_, i32>(4)? as u32,
615-
invocation_count: r.get::<_, i32>(5)? as u32,
616-
},
617-
))
618-
})
619-
.unwrap()
620-
.collect::<Result<_, _>>()
621-
.unwrap()
622-
}
623534
async fn get_error(&self, aid: crate::ArtifactIdNumber) -> HashMap<String, String> {
624535
self.raw_ref()
625536
.prepare_cached(

0 commit comments

Comments
 (0)