Skip to content

Commit 69171b7

Browse files
committed
Render link time in pipeline graph
1 parent 1891593 commit 69171b7

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/cargo/core/compiler/timings.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const CANVAS_BG = getCssColor('--canvas-background');
6767
const AXES_COLOR = getCssColor('--canvas-axes');
6868
const GRID_COLOR = getCssColor('--canvas-grid');
6969
const CODEGEN_COLOR = getCssColor('--canvas-codegen');
70+
const LINK_COLOR = getCssColor('--canvas-link');
7071
const CUSTOM_BUILD_COLOR = getCssColor('--canvas-custom-build');
7172
const NOT_CUSTOM_BUILD_COLOR = getCssColor('--canvas-not-custom-build');
7273
const DEP_LINE_COLOR = getCssColor('--canvas-dep-line');
@@ -136,7 +137,19 @@ function render_pipeline_graph() {
136137
let x = px_per_sec * unit.start;
137138

138139
const sections = [];
139-
if (unit.rmeta_time != null) {
140+
if (unit.sections !== null) {
141+
// We have access to compilation sections
142+
for (const section of unit.sections) {
143+
const [name, {start, end}] = section;
144+
sections.push({
145+
name,
146+
start: x + px_per_sec * start,
147+
width: (end - start) * px_per_sec
148+
});
149+
}
150+
}
151+
else if (unit.rmeta_time != null) {
152+
// We only know the rmeta time
140153
sections.push({
141154
name: "codegen",
142155
start: x + px_per_sec * unit.rmeta_time,
@@ -188,6 +201,8 @@ function render_pipeline_graph() {
188201
function get_section_color(name) {
189202
if (name === "codegen") {
190203
return CODEGEN_COLOR;
204+
} else if (name === "link") {
205+
return LINK_COLOR;
191206
} else {
192207
// We do not know what section this is, so just use the default color
193208
return NOT_CUSTOM_BUILD_COLOR;

src/cargo/core/compiler/timings.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ impl<'gctx> Timings<'gctx> {
586586
rmeta_time: Option<f64>,
587587
unlocked_units: Vec<usize>,
588588
unlocked_rmeta_units: Vec<usize>,
589+
sections: Option<Vec<(String, SectionData)>>,
589590
}
590591
let round = |x: f64| (x * 100.0).round() / 100.0;
591592
let unit_data: Vec<UnitData> = self
@@ -599,7 +600,6 @@ impl<'gctx> Timings<'gctx> {
599600
"todo"
600601
}
601602
.to_string();
602-
603603
// These filter on the unlocked units because not all unlocked
604604
// units are actually "built". For example, Doctest mode units
605605
// don't actually generate artifacts.
@@ -613,6 +613,13 @@ impl<'gctx> Timings<'gctx> {
613613
.iter()
614614
.filter_map(|unit| unit_map.get(unit).copied())
615615
.collect();
616+
let aggregated = ut.aggregate_sections();
617+
let sections = match aggregated {
618+
AggregatedSections::Sections(sections) => Some(sections),
619+
AggregatedSections::OnlyMetadataTime { .. }
620+
| AggregatedSections::OnlyTotalDuration => None,
621+
};
622+
616623
UnitData {
617624
i,
618625
name: ut.unit.pkg.name().to_string(),
@@ -624,6 +631,7 @@ impl<'gctx> Timings<'gctx> {
624631
rmeta_time: ut.rmeta_time.map(round),
625632
unlocked_units,
626633
unlocked_rmeta_units,
634+
sections,
627635
}
628636
})
629637
.collect();
@@ -871,6 +879,7 @@ static HTML_TMPL: &str = r#"
871879
--canvas-axes: #303030;
872880
--canvas-grid: #e6e6e6;
873881
--canvas-codegen: #aa95e8;
882+
--canvas-link: #95e8aa;
874883
--canvas-custom-build: #f0b165;
875884
--canvas-not-custom-build: #95cce8;
876885
--canvas-dep-line: #ddd;

0 commit comments

Comments
 (0)