Skip to content

Commit feee9ec

Browse files
authored
Merge pull request #900 from rylev/artifact_id
Keep usage of aid and cid straight
2 parents 55b84f4 + 88b3b3c commit feee9ec

File tree

9 files changed

+170
-141
lines changed

9 files changed

+170
-141
lines changed

collector/src/execute.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,10 @@ pub struct MeasureProcessor<'a> {
557557
krate: &'a BenchmarkName,
558558
conn: &'a mut dyn database::Connection,
559559
artifact: &'a database::ArtifactId,
560-
cid: database::ArtifactIdNumber,
560+
artifact_row_id: database::ArtifactIdNumber,
561561
upload: Option<Upload>,
562562
is_first_collection: bool,
563-
self_profile: bool,
563+
is_self_profile: bool,
564564
tries: u8,
565565
}
566566

@@ -570,8 +570,8 @@ impl<'a> MeasureProcessor<'a> {
570570
conn: &'a mut dyn database::Connection,
571571
krate: &'a BenchmarkName,
572572
artifact: &'a database::ArtifactId,
573-
cid: database::ArtifactIdNumber,
574-
self_profile: bool,
573+
artifact_row_id: database::ArtifactIdNumber,
574+
is_self_profile: bool,
575575
) -> Self {
576576
// Check we have `perf` or (`xperf.exe` and `tracelog.exe`) available.
577577
if cfg!(unix) {
@@ -596,10 +596,9 @@ impl<'a> MeasureProcessor<'a> {
596596
conn,
597597
krate,
598598
artifact,
599-
cid,
599+
artifact_row_id,
600600
is_first_collection: true,
601-
// Command::new("summarize").status().is_ok()
602-
self_profile,
601+
is_self_profile,
603602
tries: 0,
604603
}
605604
}
@@ -644,14 +643,14 @@ impl<'a> MeasureProcessor<'a> {
644643
u.wait();
645644
}
646645
let prefix = PathBuf::from("self-profile")
647-
.join(self.cid.0.to_string())
646+
.join(self.artifact_row_id.0.to_string())
648647
.join(self.krate.0.as_str())
649648
.join(profile.to_string())
650649
.join(cache.to_id());
651650
self.upload = Some(Upload::new(prefix, collection, files));
652651
self.rt.block_on(self.conn.record_raw_self_profile(
653652
collection,
654-
self.cid,
653+
self.artifact_row_id,
655654
self.krate.0.as_str(),
656655
profile,
657656
cache,
@@ -663,7 +662,7 @@ impl<'a> MeasureProcessor<'a> {
663662
for (stat, value) in stats.0.iter() {
664663
buf.push(self.conn.record_statistic(
665664
collection,
666-
self.cid,
665+
self.artifact_row_id,
667666
self.krate.0.as_str(),
668667
profile,
669668
cache,
@@ -674,12 +673,12 @@ impl<'a> MeasureProcessor<'a> {
674673

675674
if let Some(sp) = &stats.1 {
676675
let conn = &*self.conn;
677-
let cid = self.cid;
676+
let artifact_row_id = self.artifact_row_id;
678677
let krate = self.krate.0.as_str();
679678
for qd in &sp.query_data {
680679
buf.push(conn.record_self_profile_query(
681680
collection,
682-
cid,
681+
artifact_row_id,
683682
krate,
684683
profile,
685684
cache,
@@ -788,7 +787,7 @@ impl Upload {
788787

789788
impl<'a> Processor for MeasureProcessor<'a> {
790789
fn profiler(&self, _build: BuildKind) -> Profiler {
791-
if self.is_first_collection && self.self_profile {
790+
if self.is_first_collection && self.is_self_profile {
792791
if cfg!(unix) {
793792
Profiler::PerfStatSelfProfile
794793
} else {
@@ -865,7 +864,13 @@ impl<'a> Processor for MeasureProcessor<'a> {
865864
}
866865

867866
fn measure_rustc(&mut self, compiler: Compiler<'_>) -> anyhow::Result<()> {
868-
rustc::measure(self.rt, self.conn, compiler, self.artifact, self.cid)
867+
rustc::measure(
868+
self.rt,
869+
self.conn,
870+
compiler,
871+
self.artifact,
872+
self.artifact_row_id,
873+
)
869874
}
870875
}
871876

collector/src/main.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,23 @@ impl BenchmarkErrors {
186186
fn bench(
187187
rt: &mut Runtime,
188188
pool: database::Pool,
189-
cid: &ArtifactId,
189+
artifact_id: &ArtifactId,
190190
build_kinds: &[BuildKind],
191191
run_kinds: &[RunKind],
192192
compiler: Compiler<'_>,
193193
benchmarks: &[Benchmark],
194194
iterations: Option<usize>,
195-
self_profile: bool,
195+
is_self_profile: bool,
196196
) -> BenchmarkErrors {
197197
let mut conn = rt.block_on(pool.connection());
198198
let mut errors = BenchmarkErrors::new();
199-
eprintln!("Benchmarking {} for triple {}", cid, compiler.triple);
199+
eprintln!(
200+
"Benchmarking {} for triple {}",
201+
artifact_id, compiler.triple
202+
);
200203

201204
let has_measureme = Command::new("summarize").output().is_ok();
202-
if self_profile {
205+
if is_self_profile {
203206
assert!(
204207
has_measureme,
205208
"needs `summarize` in PATH for self profile.\n\
@@ -214,20 +217,20 @@ fn bench(
214217

215218
// Make sure there is no observable time when the artifact ID is available
216219
// but the in-progress steps are not.
217-
let interned_cid = {
220+
let artifact_row_id = {
218221
let mut tx = rt.block_on(conn.transaction());
219-
let interned_cid = rt.block_on(tx.conn().artifact_id(&cid));
220-
rt.block_on(tx.conn().collector_start(interned_cid, &steps));
222+
let artifact_row_id = rt.block_on(tx.conn().artifact_id(&artifact_id));
223+
rt.block_on(tx.conn().collector_start(artifact_row_id, &steps));
221224

222225
rt.block_on(tx.commit()).unwrap();
223-
interned_cid
226+
artifact_row_id
224227
};
225228

226229
let start = Instant::now();
227230
let mut skipped = false;
228231
for (nth_benchmark, benchmark) in benchmarks.iter().enumerate() {
229232
let is_fresh =
230-
rt.block_on(conn.collector_start_step(interned_cid, &benchmark.name.to_string()));
233+
rt.block_on(conn.collector_start_step(artifact_row_id, &benchmark.name.to_string()));
231234
if !is_fresh {
232235
skipped = true;
233236
eprintln!("skipping {} -- already benchmarked", benchmark.name);
@@ -247,9 +250,9 @@ fn bench(
247250
rt,
248251
tx.conn(),
249252
&benchmark.name,
250-
&cid,
251-
interned_cid,
252-
self_profile,
253+
&artifact_id,
254+
artifact_row_id,
255+
is_self_profile,
253256
);
254257
let result =
255258
benchmark.measure(&mut processor, build_kinds, run_kinds, compiler, iterations);
@@ -260,14 +263,14 @@ fn bench(
260263
);
261264
errors.incr();
262265
rt.block_on(tx.conn().record_error(
263-
interned_cid,
266+
artifact_row_id,
264267
benchmark.name.0.as_str(),
265268
&format!("{:?}", s),
266269
));
267270
};
268271
rt.block_on(
269272
tx.conn()
270-
.collector_end_step(interned_cid, &benchmark.name.to_string()),
273+
.collector_end_step(artifact_row_id, &benchmark.name.to_string()),
271274
);
272275
rt.block_on(tx.commit()).expect("committed");
273276
}
@@ -281,7 +284,7 @@ fn bench(
281284
if skipped {
282285
log::info!("skipping duration record -- skipped parts of run");
283286
} else {
284-
rt.block_on(conn.record_duration(interned_cid, end));
287+
rt.block_on(conn.record_duration(artifact_row_id, end));
285288
}
286289

287290
rt.block_on(async move {
@@ -574,7 +577,7 @@ fn main_result() -> anyhow::Result<i32> {
574577
let include = sub_m.value_of("INCLUDE");
575578
let run_kinds = run_kinds_from_arg(&sub_m.value_of("RUNS"))?;
576579
let rustdoc = sub_m.value_of("RUSTDOC");
577-
let self_profile = sub_m.is_present("SELF_PROFILE");
580+
let is_self_profile = sub_m.is_present("SELF_PROFILE");
578581

579582
let pool = database::Pool::open(db);
580583

@@ -597,7 +600,7 @@ fn main_result() -> anyhow::Result<i32> {
597600
},
598601
&benchmarks,
599602
Some(1),
600-
self_profile,
603+
is_self_profile,
601604
);
602605
res.fail_if_nonzero()?;
603606
Ok(0)
@@ -609,7 +612,7 @@ fn main_result() -> anyhow::Result<i32> {
609612

610613
// Options
611614
let db = sub_m.value_of("DB").unwrap_or(default_db);
612-
let self_profile = sub_m.is_present("SELF_PROFILE");
615+
let is_self_profile = sub_m.is_present("SELF_PROFILE");
613616

614617
println!("processing commits");
615618
let client = reqwest::blocking::Client::new();
@@ -646,7 +649,7 @@ fn main_result() -> anyhow::Result<i32> {
646649
Compiler::from_sysroot(&sysroot),
647650
&benchmarks,
648651
next.runs.map(|v| v as usize),
649-
self_profile,
652+
is_self_profile,
650653
);
651654

652655
client.post(&format!("{}/perf/onpush", site_url)).send()?;
@@ -722,7 +725,7 @@ fn main_result() -> anyhow::Result<i32> {
722725
},
723726
&benchmarks,
724727
Some(3),
725-
/* self_profile */ false,
728+
/* is_self_profile */ false,
726729
);
727730
res.fail_if_nonzero()?;
728731
Ok(0)

database/src/lib.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,21 @@ impl From<Commit> for ArtifactId {
417417

418418
#[async_trait::async_trait]
419419
pub trait SeriesType: Sized {
420-
async fn get(conn: &dyn pool::Connection, series: u32, cid: ArtifactIdNumber) -> Option<Self>;
420+
async fn get(
421+
conn: &dyn pool::Connection,
422+
series: u32,
423+
artifact_row_id: ArtifactIdNumber,
424+
) -> Option<Self>;
421425
}
422426

423427
#[async_trait::async_trait]
424428
impl SeriesType for f64 {
425-
async fn get(conn: &dyn pool::Connection, series: u32, cid: ArtifactIdNumber) -> Option<Self> {
426-
conn.get_pstats(&[series], &[Some(cid)]).await[0][0]
429+
async fn get(
430+
conn: &dyn pool::Connection,
431+
series: u32,
432+
artifact_row_id: ArtifactIdNumber,
433+
) -> Option<Self> {
434+
conn.get_pstats(&[series], &[Some(artifact_row_id)]).await[0][0]
427435
}
428436
}
429437

@@ -440,13 +448,18 @@ pub struct QueryDatum {
440448

441449
#[async_trait::async_trait]
442450
impl SeriesType for QueryDatum {
443-
async fn get(conn: &dyn pool::Connection, series: u32, cid: ArtifactIdNumber) -> Option<Self> {
444-
conn.get_self_profile_query(series, cid).await
451+
async fn get(
452+
conn: &dyn pool::Connection,
453+
series: u32,
454+
artifact_row_id: ArtifactIdNumber,
455+
) -> Option<Self> {
456+
conn.get_self_profile_query(series, artifact_row_id).await
445457
}
446458
}
447459
#[derive(Hash, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
448460
pub struct LabelId(pub u8, pub u32);
449461

462+
/// A database row ID for an artifact in the artifact table
450463
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
451464
pub struct ArtifactIdNumber(pub u32);
452465

@@ -638,20 +651,24 @@ impl Index {
638651
conn.load_index().await
639652
}
640653

641-
pub fn lookup(&self, path: &DbLabel, cid: &ArtifactId) -> Option<(u32, ArtifactIdNumber)> {
642-
let cid = cid.lookup(self)?;
654+
pub fn lookup(
655+
&self,
656+
path: &DbLabel,
657+
artifact_id: &ArtifactId,
658+
) -> Option<(u32, ArtifactIdNumber)> {
659+
let artifact_row_id = artifact_id.lookup(self)?;
643660
let series = path.lookup(self)?;
644-
Some((series, cid))
661+
Some((series, artifact_row_id))
645662
}
646663

647664
pub async fn get<T: SeriesType>(
648665
&self,
649666
db: &mut dyn pool::Connection,
650667
path: &DbLabel,
651-
cid: &ArtifactId,
668+
artifact_id: &ArtifactId,
652669
) -> Option<T> {
653-
let (series, cid) = self.lookup(path, cid)?;
654-
T::get(db, series, cid).await
670+
let (series, artifact_row_id) = self.lookup(path, artifact_id)?;
671+
T::get(db, series, artifact_row_id).await
655672
}
656673

657674
pub fn artifacts(&self) -> impl Iterator<Item = &'_ str> + '_ {

database/src/pool.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,22 @@ pub trait Connection: Send + Sync {
7575
async fn get_pstats(
7676
&self,
7777
series: &[u32],
78-
cid: &[Option<ArtifactIdNumber>],
78+
artifact_row_id: &[Option<ArtifactIdNumber>],
7979
) -> Vec<Vec<Option<f64>>>;
8080
async fn get_self_profile(
8181
&self,
82-
cid: ArtifactIdNumber,
82+
artifact_row_id: ArtifactIdNumber,
8383
crate_: &str,
8484
profile: &str,
8585
cache: &str,
8686
) -> HashMap<crate::QueryLabel, QueryDatum>;
8787
async fn get_self_profile_query(
8888
&self,
8989
series: u32,
90-
cid: ArtifactIdNumber,
90+
artifact_row_id: ArtifactIdNumber,
9191
) -> Option<QueryDatum>;
92-
async fn get_error(&self, cid: ArtifactIdNumber) -> HashMap<String, Option<String>>;
92+
async fn get_error(&self, artifact_row_id: ArtifactIdNumber)
93+
-> HashMap<String, Option<String>>;
9394

9495
async fn queue_pr(
9596
&self,

0 commit comments

Comments
 (0)