Skip to content

Commit 8d9ecf2

Browse files
Permit loading artifacts for self-profile view
Also correct sqlite query to lookup by artifact not collection id.
1 parent a42f4c4 commit 8d9ecf2

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

database/src/pool/sqlite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl Connection for SqliteConnection {
353353
self.raw_ref().prepare_cached("
354354
select self_time, blocked_time, incremental_load_time, number_of_cache_hits, invocation_count
355355
from self_profile_query
356-
where series = ? and cid = ? order by self_time asc;").unwrap()
356+
where series = ? and aid = ? order by self_time asc;").unwrap()
357357
.query_row(params![&series, &cid.0], |row| {
358358
let self_time: i64 = row.get(0)?;
359359
let blocked_time: i64 = row.get(1)?;

site/src/server.rs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ pub async fn handle_self_profile(
658658
let mut it = body.benchmark.rsplitn(2, '-');
659659
let bench_ty = it.next().ok_or(format!("no benchmark type"))?;
660660
let bench_name = it.next().ok_or(format!("no benchmark name"))?;
661+
let index = data.index.load();
661662

662663
let sort_idx = body
663664
.sort_idx
@@ -670,26 +671,33 @@ pub async fn handle_self_profile(
670671
.set(Tag::Profile, selector::Selector::One(bench_ty))
671672
.set(Tag::Cache, selector::Selector::One(body.run_name.clone()));
672673

673-
let mut commits = vec![data
674-
.index
675-
.load()
674+
let mut commits = vec![index
676675
.commits()
677676
.iter()
678677
.find(|c| c.sha == *body.commit.as_str())
679-
.cloned()
680-
.ok_or(format!("could not find commit {}", body.commit))?
681-
.into()];
678+
.map(|c| database::ArtifactId::Commit(*c))
679+
.or_else(|| {
680+
index
681+
.artifacts()
682+
.find(|a| **a == body.commit)
683+
.map(|a| database::ArtifactId::Artifact(a.to_owned()))
684+
})
685+
.ok_or(format!("could not find artifact {}", body.commit))?];
682686

683687
if let Some(bc) = &body.base_commit {
684688
commits.push(
685-
data.index
686-
.load()
689+
index
687690
.commits()
688691
.iter()
689692
.find(|c| c.sha == *bc.as_str())
690-
.cloned()
691-
.ok_or(format!("could not find base commit {}", body.commit))?
692-
.into(),
693+
.map(|c| database::ArtifactId::Commit(*c))
694+
.or_else(|| {
695+
index
696+
.artifacts()
697+
.find(|a| **a == *bc.as_str())
698+
.map(|a| database::ArtifactId::Artifact(a.to_owned()))
699+
})
700+
.ok_or(format!("could not find artifact {}", body.commit))?,
693701
);
694702
}
695703

@@ -716,13 +724,17 @@ pub async fn handle_self_profile(
716724
cpu_response.next().unwrap().1,
717725
sp_response.next().unwrap().1,
718726
Some(sort_idx),
719-
)?;
727+
)
728+
.map_err(|e| format!("{}: {}", body.commit, e))?;
720729
let base_profile = if body.base_commit.is_some() {
721-
Some(get_self_profile_data(
722-
cpu_response.next().unwrap().1,
723-
sp_response.next().unwrap().1,
724-
None,
725-
)?)
730+
Some(
731+
get_self_profile_data(
732+
cpu_response.next().unwrap().1,
733+
sp_response.next().unwrap().1,
734+
None,
735+
)
736+
.map_err(|e| format!("{}: {}", body.base_commit.as_ref().unwrap(), e))?,
737+
)
726738
} else {
727739
None
728740
};

0 commit comments

Comments
 (0)