Skip to content

Revert "Graph total bootstrap time" #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions database/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,8 @@ pub trait Connection: Send + Sync {
krate: &str,
value: Duration,
);
/// Returns vector of bootstrap build times for the given artifacts. The kth
/// element is the minimum build time for the kth artifact in `aids`, across
/// all collections for the artifact, or none if there is no bootstrap data
/// for that artifact (for example, because the rustc benchmark wasn't
/// executed for that artifact).
async fn get_bootstrap(&self, aids: &[ArtifactIdNumber]) -> Vec<Option<Duration>>;
/// Returns map from rustc crate name to vector of build times for that crate
/// for the given artifacts. Within a crate's corresponding vector, the kth
/// element is the minimum build time for the kth artifact in `aids`, across
/// all collections for the artifact, or none if there is no data for that
/// artifact / crate combination (for example, because that rustc crate
/// wasn't present when building rustc with that artifact, or because the
/// rustc benchmark wasn't executed for that artifact). A crate will not be
/// included as a key in the map unless at least one artifact in `aids` has a
/// build time for it.
async fn get_bootstrap_by_crate(

async fn get_bootstrap(
&self,
aids: &[ArtifactIdNumber],
) -> HashMap<String, Vec<Option<Duration>>>;
Expand Down
44 changes: 2 additions & 42 deletions database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ impl<'a> Transaction for PostgresTransaction<'a> {
pub struct CachedStatements {
get_pstat: Statement,
get_rustc_compilation: Statement,
get_rustc_compilation_by_crate: Statement,
insert_pstat: Statement,
insert_rustc: Statement,
get_self_profile_query: Statement,
Expand Down Expand Up @@ -357,16 +356,6 @@ impl PostgresConnection {
.await
.unwrap(),
get_rustc_compilation: conn.prepare("
select aid, min(total)
from (
select aid, sum(duration) as total
from rustc_compilation
where aid = any($1)
group by cid
)
group by aid
").await.unwrap(),
get_rustc_compilation_by_crate: conn.prepare("
select
aid,
crate,
Expand Down Expand Up @@ -1195,36 +1184,7 @@ where
.collect()
}

async fn get_bootstrap(&self, aids: &[ArtifactIdNumber]) -> Vec<Option<Duration>> {
let mut result = vec![None; aids.len()];

let aid_to_idx = aids
.iter()
.copied()
.enumerate()
.map(|(idx, v)| (v, idx))
.collect::<HashMap<ArtifactIdNumber, usize>>();

let rows = self
.conn()
.query(
&self.statements().get_rustc_compilation,
&[&aids.iter().map(|v| v.0 as i32).collect::<Vec<_>>()],
)
.await
.unwrap();

for row in rows {
let aid = ArtifactIdNumber(row.get::<_, i32>(0) as u32);
let min_duration = row.get::<_, i64>(1);

result[aid_to_idx[&aid]] = Some(Duration::from_nanos(min_duration as u64));
}

result
}

async fn get_bootstrap_by_crate(
async fn get_bootstrap(
&self,
aids: &[ArtifactIdNumber],
) -> HashMap<String, Vec<Option<Duration>>> {
Expand All @@ -1238,7 +1198,7 @@ where
let rows = self
.conn()
.query(
&self.statements().get_rustc_compilation_by_crate,
&self.statements().get_rustc_compilation,
&[&aids.iter().map(|v| v.0 as i32).collect::<Vec<_>>()],
)
.await
Expand Down
37 changes: 8 additions & 29 deletions database/src/pool/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,32 +911,7 @@ impl Connection for SqliteConnection {
Vec::new()
}

async fn get_bootstrap(&self, aids: &[ArtifactIdNumber]) -> Vec<Option<Duration>> {
aids.into_iter()
.map(|aid| {
self.raw_ref()
.prepare(
"
select min(total)
from (
select sum(duration) as total
from rustc_compilation
where aid = ?
group by cid
)
",
)
.unwrap()
.query_row(params![&aid.0], |row| {
Ok(Duration::from_nanos(row.get::<_, i64>(0)? as u64))
})
.optional()
.unwrap()
})
.collect()
}

async fn get_bootstrap_by_crate(
async fn get_bootstrap(
&self,
aids: &[ArtifactIdNumber],
) -> HashMap<String, Vec<Option<Duration>>> {
Expand All @@ -953,11 +928,15 @@ impl Connection for SqliteConnection {
.unwrap()
.map(|r| r.unwrap())
.collect();
for (krate, min_duration) in rows {
for (krate, duration) in rows {
let v = results
.entry(krate)
.or_insert_with(|| vec![None; aids.len()]);
v[idx] = Some(Duration::from_nanos(min_duration as u64));
.or_insert_with(|| Vec::with_capacity(aids.len()));

if v.len() != idx {
v.resize_with(idx, || None);
}
v.push(Some(Duration::from_nanos(duration as u64)));
}
}

Expand Down
4 changes: 1 addition & 3 deletions site/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ pub mod bootstrap {
// (UTC timestamp, sha)
pub commits: Vec<(i64, String)>,
// Optional nanoseconds
pub by_crate_build_times: HashMap<String, Vec<Option<u64>>>,
// Each commit's total rustc build time in nanoseconds
pub total_build_times: Vec<Option<u64>>,
pub by_crate: HashMap<String, Vec<Option<u64>>>,
}
}

Expand Down
2 changes: 1 addition & 1 deletion site/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl ArtifactData {
let data = data_from_series(series);

let bootstrap = conn
.get_bootstrap_by_crate(&[conn.artifact_id(&artifact).await])
.get_bootstrap(&[conn.artifact_id(&artifact).await])
.await;
let bootstrap = bootstrap
.into_iter()
Expand Down
36 changes: 16 additions & 20 deletions site/src/request_handlers/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use crate::api::{bootstrap, ServerResult};
use crate::db::ArtifactId;
use crate::load::SiteCtxt;

use std::time::Duration;

pub async fn handle_bootstrap(
body: bootstrap::Request,
ctxt: &SiteCtxt,
) -> ServerResult<bootstrap::Response> {
log::info!("handle_bootstrap({:?})", body);
let range = ctxt.data_range(body.start.clone()..=body.end.clone());
let commits: Vec<ArtifactId> = range.iter().map(|c| c.clone().into()).collect();
let mut commits: Vec<ArtifactId> = range.iter().map(|c| c.clone().into()).collect();

let conn = ctxt.conn().await;
let ids = commits
Expand All @@ -21,14 +19,8 @@ pub async fn handle_bootstrap(
.collect::<FuturesOrdered<_>>()
.collect::<Vec<_>>()
.await;

let by_crate_build_times = conn.get_bootstrap_by_crate(&ids).await;

fn duration_as_nanos_u64(d: Duration) -> u64 {
d.as_nanos() as u64
}

let by_crate_build_times = by_crate_build_times
let by_crate = conn.get_bootstrap(&ids).await;
let mut by_crate = by_crate
.into_iter()
.filter_map(|(k, v)| {
// We show any line that has at least one point exceeding the
Expand All @@ -37,7 +29,7 @@ pub async fn handle_bootstrap(
Some((
k,
v.into_iter()
.map(|v| v.map(duration_as_nanos_u64))
.map(|v| v.map(|d| d.as_nanos() as u64))
.collect(),
))
} else {
Expand All @@ -46,12 +38,17 @@ pub async fn handle_bootstrap(
})
.collect::<hashbrown::HashMap<String, Vec<Option<u64>>>>();

let total_build_times = conn
.get_bootstrap(&ids)
.await
.into_iter()
.map(|v| v.map(duration_as_nanos_u64))
.collect();
// Don't return commits/nulls for completely null commits at the beginning
let start: usize = by_crate
.values()
.filter_map(|series| series.iter().position(|v| v.is_some()))
.min()
.unwrap_or(0);

commits = commits.split_off(start);
for series in by_crate.values_mut() {
*series = series.split_off(start);
}

Ok(bootstrap::Response {
commits: commits
Expand All @@ -61,7 +58,6 @@ pub async fn handle_bootstrap(
ArtifactId::Tag(_) => todo!(),
})
.collect(),
by_crate_build_times,
total_build_times,
by_crate,
})
}
39 changes: 12 additions & 27 deletions site/static/bootstrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@
<h2>Loading &amp; rendering data..</h2>
<h3>This may take a while!</h3>
</div>
<div id="byCrateChart"></div>
<div id="totalChart"></div>
<div id="charts"></div>
<div id="as-of"></div>
<a href="https://github.com/rust-lang-nursery/rustc-perf">
<img style="position: absolute; top: 0; right: 0; border: 0;"
Expand Down Expand Up @@ -233,50 +232,36 @@ <h3>This may take a while!</h3>
}

function renderPlots(data, state) {
let byChartSeriesOpts = [{}];
let seriesOpts = [{}];

let xVals = data.commits.map(c => c[0]);
let byChartPlotData = [xVals];
let plotData = [xVals];
// https://sashamaps.net/docs/resources/20-colors/
let colors = [
'#e6194b', '#3cb44b', '#ffe119', '#4363d8', '#f58231',
'#911eb4', '#46f0f0', '#f032e6', '#a09b13', '#0ab0be',
'red', 'green', 'blue', 'purple'
];
let crates = Object.keys(data.by_crate_build_times).sort();
let crates = Object.keys(data.by_crate).sort();
for (let crate of crates) {
byChartPlotData.push(data.by_crate_build_times[crate]);
plotData.push(data.by_crate[crate]);

byChartSeriesOpts.push({
seriesOpts.push({
label: crate,
stroke: colors.length ? colors.pop() : 'black',
});
}

let byChartPlotOpts = genPlotOpts({
title: "Bootstrap time for crates >= 30 seconds",
let plotOpts = genPlotOpts({
title: "Bootstrap timings for crates >= 30 seconds",
width: Math.floor(window.innerWidth) - 16,
height: window.innerHeight * 0.56,
height: window.innerHeight * 0.75,
yAxisLabel: "",
series: byChartSeriesOpts,
series: seriesOpts,
commits: data.commits,
});

let byChartPlot = new uPlot(byChartPlotOpts, byChartPlotData, document.querySelector("#byCrateChart"));

let totalPlotData = [xVals, data.total_build_times];

let totalPlotOpts = genPlotOpts({
title: "Total bootstrap time",
width: Math.floor(window.innerWidth) - 16,
height: window.innerHeight * 0.26,
yAxisLabel: "",
series: [{}, { label: "rustc", stroke: '#7cb5ec' }],
commits: data.commits,
});

let totalPlot = new uPlot(totalPlotOpts, totalPlotData, document.querySelector("#totalChart"));

let u = new uPlot(plotOpts, plotData, document.querySelector("#charts"));
document.querySelector("#loading").style.display = 'none';
}

Expand Down Expand Up @@ -306,4 +291,4 @@ <h3>This may take a while!</h3>
</script>
</body>

</html>
</html>