diff --git a/compiler/hash-link/src/linker/mod.rs b/compiler/hash-link/src/linker/mod.rs index 925060891..fb913c540 100644 --- a/compiler/hash-link/src/linker/mod.rs +++ b/compiler/hash-link/src/linker/mod.rs @@ -1,6 +1,7 @@ //! Defines a generic linker interface and functions that create //! an instance of a [Linker] with the provided compiler settings //! and target options. +#![allow(dead_code)] // @@Temporary: remove when all linker methods are used. use std::{ ffi::{OsStr, OsString}, diff --git a/compiler/hash-lower/src/lib.rs b/compiler/hash-lower/src/lib.rs index b3bad2344..2c61bda6d 100644 --- a/compiler/hash-lower/src/lib.rs +++ b/compiler/hash-lower/src/lib.rs @@ -204,7 +204,7 @@ impl CompilerStage for IrOptimiser { let bodies = &mut icx.bodies; let body_data = &icx.ctx; - self.time_item("optimise", |_| { + self.time_item("optimise", |this| { // @@Todo: think about making optimisation passes in parallel... // pool.scope(|scope| { // for body in &mut icx.generated_bodies { @@ -218,6 +218,10 @@ impl CompilerStage for IrOptimiser { for body in bodies.iter_mut() { let optimiser = Optimiser::new(body_data, settings); optimiser.optimise(body); + + // Collect metrics on the stages. + let metrics = optimiser.into_metrics().into(); + this.metrics().merge(&metrics); } }); diff --git a/compiler/hash-lower/src/optimise/cleanup_locals.rs b/compiler/hash-lower/src/optimise/cleanup_locals.rs index 3fa88d0df..267c2dd2d 100644 --- a/compiler/hash-lower/src/optimise/cleanup_locals.rs +++ b/compiler/hash-lower/src/optimise/cleanup_locals.rs @@ -29,7 +29,7 @@ pub struct CleanupLocalPass; impl IrOptimisationPass for CleanupLocalPass { fn name(&self) -> &'static str { - "cleanup_locals" + "optimise::cleanup_locals" } /// Pass [CleanupLocalPass] is always enabled since it performs diff --git a/compiler/hash-lower/src/optimise/mod.rs b/compiler/hash-lower/src/optimise/mod.rs index d8a375374..d76979faf 100644 --- a/compiler/hash-lower/src/optimise/mod.rs +++ b/compiler/hash-lower/src/optimise/mod.rs @@ -8,6 +8,7 @@ use hash_ir::{ir::Body, IrCtx}; use hash_pipeline::settings::{CompilerSettings, OptimisationLevel}; +use hash_utils::timing::{CellStageMetrics, HasMetrics}; // Various passes that are used to optimise the generated IR bodies. mod cleanup_locals; @@ -40,6 +41,9 @@ pub struct Optimiser<'ir> { /// The various passes that have been added to the optimisation /// pipeline. passes: Vec>, + + /// Metrics for each of the passes. + metrics: CellStageMetrics, } impl<'ir> Optimiser<'ir> { @@ -51,6 +55,7 @@ impl<'ir> Optimiser<'ir> { Box::new(simplify_graph::SimplifyGraphPass), Box::new(cleanup_locals::CleanupLocalPass), ], + metrics: CellStageMetrics::default(), } } @@ -59,8 +64,20 @@ impl<'ir> Optimiser<'ir> { pub fn optimise(&self, body: &mut Body) { for pass in self.passes.iter() { if pass.enabled(self.settings) { - pass.optimise(body, self.store); + self.time_item(pass.name(), |this| { + pass.optimise(body, this.store); + }) } } } + + pub fn into_metrics(self) -> CellStageMetrics { + self.metrics + } +} + +impl HasMetrics for Optimiser<'_> { + fn metrics(&self) -> &CellStageMetrics { + &self.metrics + } } diff --git a/compiler/hash-lower/src/optimise/simplify_graph.rs b/compiler/hash-lower/src/optimise/simplify_graph.rs index b981524b2..f00efb9af 100644 --- a/compiler/hash-lower/src/optimise/simplify_graph.rs +++ b/compiler/hash-lower/src/optimise/simplify_graph.rs @@ -94,7 +94,7 @@ pub struct SimplifyGraphPass; impl IrOptimisationPass for SimplifyGraphPass { fn name(&self) -> &'static str { - "simplify-graph" + "optimise::simplify_graph" } fn enabled(&self, settings: &CompilerSettings) -> bool {