Skip to content

Commit 80912b6

Browse files
committed
Add "Other" section after linking
1 parent 1243748 commit 80912b6

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/cargo/core/compiler/timings.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ const AXES_COLOR = getCssColor('--canvas-axes');
6868
const GRID_COLOR = getCssColor('--canvas-grid');
6969
const CODEGEN_COLOR = getCssColor('--canvas-codegen');
7070
const LINK_COLOR = getCssColor('--canvas-link');
71+
// Final leftover section after link
72+
const OTHER_COLOR = getCssColor('--canvas-other');
7173
const CUSTOM_BUILD_COLOR = getCssColor('--canvas-custom-build');
7274
const NOT_CUSTOM_BUILD_COLOR = getCssColor('--canvas-not-custom-build');
7375
const DEP_LINE_COLOR = getCssColor('--canvas-dep-line');
@@ -222,6 +224,13 @@ function render_pipeline_graph() {
222224
line: false
223225
});
224226
}
227+
if (presentSections.has("other")) {
228+
legend_entries.push({
229+
name: "Other",
230+
color: OTHER_COLOR,
231+
line: false
232+
});
233+
}
225234
draw_legend(ctx, 160, legend_entries);
226235
ctx.restore();
227236
}
@@ -289,6 +298,8 @@ function get_section_color(name) {
289298
return CODEGEN_COLOR;
290299
} else if (name === "link") {
291300
return LINK_COLOR;
301+
} else if (name === "other") {
302+
return OTHER_COLOR;
292303
} else {
293304
// We do not know what section this is, so just use the default color
294305
return NOT_CUSTOM_BUILD_COLOR;

src/cargo/core/compiler/timings.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,27 @@ impl<'gctx> Timings<'gctx> {
615615
.collect();
616616
let aggregated = ut.aggregate_sections();
617617
let sections = match aggregated {
618-
AggregatedSections::Sections(sections) => Some(sections),
618+
AggregatedSections::Sections(mut sections) => {
619+
// We draw the sections in the pipeline graph in a way where the frontend
620+
// section has the "default" build color, and then additional sections
621+
// (codegen, link) are overlayed on top with a different color.
622+
// However, there might be some time after the final (usually link) section,
623+
// which definitely shouldn't be classified as "Frontend". We thus try to
624+
// detect this situation and add a final "Other" section.
625+
if let Some((_, section)) = sections.last()
626+
&& section.end < ut.duration
627+
{
628+
sections.push((
629+
"other".to_string(),
630+
SectionData {
631+
start: section.end,
632+
end: ut.duration,
633+
},
634+
));
635+
}
636+
637+
Some(sections)
638+
}
619639
AggregatedSections::OnlyMetadataTime { .. }
620640
| AggregatedSections::OnlyTotalDuration => None,
621641
};
@@ -880,6 +900,7 @@ static HTML_TMPL: &str = r#"
880900
--canvas-grid: #e6e6e6;
881901
--canvas-codegen: #aa95e8;
882902
--canvas-link: #95e8aa;
903+
--canvas-other: #e895aa;
883904
--canvas-custom-build: #f0b165;
884905
--canvas-not-custom-build: #95cce8;
885906
--canvas-dep-line: #ddd;

0 commit comments

Comments
 (0)