Render link time in pipeline graph

This commit is contained in:
Jakub Beránek 2025-09-04 10:21:54 +02:00
parent 18915936bd
commit 69171b7e81
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
2 changed files with 26 additions and 2 deletions

View File

@ -67,6 +67,7 @@ const CANVAS_BG = getCssColor('--canvas-background');
const AXES_COLOR = getCssColor('--canvas-axes');
const GRID_COLOR = getCssColor('--canvas-grid');
const CODEGEN_COLOR = getCssColor('--canvas-codegen');
const LINK_COLOR = getCssColor('--canvas-link');
const CUSTOM_BUILD_COLOR = getCssColor('--canvas-custom-build');
const NOT_CUSTOM_BUILD_COLOR = getCssColor('--canvas-not-custom-build');
const DEP_LINE_COLOR = getCssColor('--canvas-dep-line');
@ -136,7 +137,19 @@ function render_pipeline_graph() {
let x = px_per_sec * unit.start;
const sections = [];
if (unit.rmeta_time != null) {
if (unit.sections !== null) {
// We have access to compilation sections
for (const section of unit.sections) {
const [name, {start, end}] = section;
sections.push({
name,
start: x + px_per_sec * start,
width: (end - start) * px_per_sec
});
}
}
else if (unit.rmeta_time != null) {
// We only know the rmeta time
sections.push({
name: "codegen",
start: x + px_per_sec * unit.rmeta_time,
@ -188,6 +201,8 @@ function render_pipeline_graph() {
function get_section_color(name) {
if (name === "codegen") {
return CODEGEN_COLOR;
} else if (name === "link") {
return LINK_COLOR;
} else {
// We do not know what section this is, so just use the default color
return NOT_CUSTOM_BUILD_COLOR;

View File

@ -586,6 +586,7 @@ impl<'gctx> Timings<'gctx> {
rmeta_time: Option<f64>,
unlocked_units: Vec<usize>,
unlocked_rmeta_units: Vec<usize>,
sections: Option<Vec<(String, SectionData)>>,
}
let round = |x: f64| (x * 100.0).round() / 100.0;
let unit_data: Vec<UnitData> = self
@ -599,7 +600,6 @@ impl<'gctx> Timings<'gctx> {
"todo"
}
.to_string();
// These filter on the unlocked units because not all unlocked
// units are actually "built". For example, Doctest mode units
// don't actually generate artifacts.
@ -613,6 +613,13 @@ impl<'gctx> Timings<'gctx> {
.iter()
.filter_map(|unit| unit_map.get(unit).copied())
.collect();
let aggregated = ut.aggregate_sections();
let sections = match aggregated {
AggregatedSections::Sections(sections) => Some(sections),
AggregatedSections::OnlyMetadataTime { .. }
| AggregatedSections::OnlyTotalDuration => None,
};
UnitData {
i,
name: ut.unit.pkg.name().to_string(),
@ -624,6 +631,7 @@ impl<'gctx> Timings<'gctx> {
rmeta_time: ut.rmeta_time.map(round),
unlocked_units,
unlocked_rmeta_units,
sections,
}
})
.collect();
@ -871,6 +879,7 @@ static HTML_TMPL: &str = r#"
--canvas-axes: #303030;
--canvas-grid: #e6e6e6;
--canvas-codegen: #aa95e8;
--canvas-link: #95e8aa;
--canvas-custom-build: #f0b165;
--canvas-not-custom-build: #95cce8;
--canvas-dep-line: #ddd;