@@ -706,13 +706,33 @@ def print_free_disk_space(pipeline: Pipeline):
706706 f"Free disk space: { format_bytes (free )} out of total { format_bytes (total )} ({ (used / total ) * 100 :.2f} % used)" )
707707
708708
709+ def log_metrics (step : BuildStep ):
710+ substeps : List [Tuple [int , BuildStep ]] = []
711+
712+ def visit (step : BuildStep , level : int ):
713+ substeps .append ((level , step ))
714+ for child in step .children :
715+ visit (child , level = level + 1 )
716+
717+ visit (step , 0 )
718+
719+ output = StringIO ()
720+ for (level , step ) in substeps :
721+ label = f"{ '.' * level } { step .type } "
722+ print (f"{ label :<65} { step .duration :>8.2f} s" , file = output )
723+ logging .info (f"Build step durations\n { output .getvalue ()} " )
724+
725+
709726def record_metrics (pipeline : Pipeline , timer : Timer ):
710727 metrics = load_last_metrics (pipeline .metrics_path ())
711728 if metrics is None :
712729 return
713- llvm_steps = metrics .find_all_by_type ("bootstrap::native::Llvm" )
730+ llvm_steps = tuple (metrics .find_all_by_type ("bootstrap::native::Llvm" ))
731+ assert len (llvm_steps ) > 0
714732 llvm_duration = sum (step .duration for step in llvm_steps )
715- rustc_steps = metrics .find_all_by_type ("bootstrap::compile::Rustc" )
733+
734+ rustc_steps = tuple (metrics .find_all_by_type ("bootstrap::compile::Rustc" ))
735+ assert len (rustc_steps ) > 0
716736 rustc_duration = sum (step .duration for step in rustc_steps )
717737
718738 # The LLVM step is part of the Rustc step
@@ -721,6 +741,8 @@ def record_metrics(pipeline: Pipeline, timer: Timer):
721741 timer .add_duration ("LLVM" , llvm_duration )
722742 timer .add_duration ("Rustc" , rustc_duration )
723743
744+ log_metrics (metrics )
745+
724746
725747def execute_build_pipeline (timer : Timer , pipeline : Pipeline , final_build_args : List [str ]):
726748 # Clear and prepare tmp directory
0 commit comments