Skip to content

Commit 33be686

Browse files
authored
refactor(timings): store UnitData in RenderContext instead (#16346)
### What does this PR try to resolve? This makes `RenderContext` more self-contained, so it no longer relies on full `Unit` info and can potentially be replayed from a log file. Part of <#15844>. ### How to test and review this PR? Compare HTML report before and after to ensure it is not broken: ``` cargo clean rustup run nightly target/debug/cargo build --timings -p cargo-util cargo clean rustup run nightly target/debug/cargo build --timings -p cargo-util -Zsection-timings ``` This should have no change on end-user side (except the first commit removing `/rest`)
2 parents 90db5c5 + 6741b04 commit 33be686

File tree

3 files changed

+155
-184
lines changed

3 files changed

+155
-184
lines changed

src/cargo/core/compiler/timings/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ struct Concurrency {
125125
/// This is used by the HTML report's JavaScript to render the pipeline graph.
126126
#[derive(serde::Serialize)]
127127
struct UnitData {
128-
i: usize,
128+
i: u64,
129129
name: String,
130130
version: String,
131131
mode: String,
132132
target: String,
133+
features: Vec<String>,
133134
start: f64,
134135
duration: f64,
135-
rmeta_time: Option<f64>,
136-
unblocked_units: Vec<usize>,
137-
unblocked_rmeta_units: Vec<usize>,
138-
sections: Option<Vec<(String, report::SectionData)>>,
136+
unblocked_units: Vec<u64>,
137+
unblocked_rmeta_units: Vec<u64>,
138+
sections: Option<Vec<(report::SectionName, report::SectionData)>>,
139139
}
140140

141141
impl<'gctx> Timings<'gctx> {
@@ -472,14 +472,16 @@ impl<'gctx> Timings<'gctx> {
472472
.map(|kind| build_runner.bcx.target_data.short_name(kind))
473473
.collect::<Vec<_>>();
474474

475+
let unit_data = report::to_unit_data(&self.unit_times, &self.unit_to_index);
476+
475477
let ctx = report::RenderContext {
476478
start: self.start,
477479
start_str: &self.start_str,
478480
root_units: &self.root_targets,
479481
profile: &self.profile,
480482
total_fresh: self.total_fresh,
481483
total_dirty: self.total_dirty,
482-
unit_times: &self.unit_times,
484+
unit_data,
483485
concurrency: &self.concurrency,
484486
cpu_usage: &self.cpu_usage,
485487
rustc_version,
@@ -504,10 +506,6 @@ impl<'gctx> Timings<'gctx> {
504506
}
505507

506508
impl UnitTime {
507-
fn name_ver(&self) -> String {
508-
format!("{} v{}", self.unit.pkg.name(), self.unit.pkg.version())
509-
}
510-
511509
fn start_section(&mut self, name: &str, now: f64) {
512510
if self
513511
.sections

0 commit comments

Comments
 (0)