@@ -211,7 +211,8 @@ def get_timestamp() -> float:
211211TimerSection = Union [Duration , "Timer" ]
212212
213213
214- def iterate_sections (section : TimerSection , name : str , level : int = 0 ) -> Iterator [Tuple [int , str , Duration ]]:
214+ def iterate_sections (section : TimerSection , name : str , level : int = 0 ) -> Iterator [
215+ Tuple [int , str , Duration ]]:
215216 """
216217 Hierarchically iterate the sections of a timer, in a depth-first order.
217218 """
@@ -239,7 +240,7 @@ def section(self, name: str) -> "Timer":
239240 start = get_timestamp ()
240241 exc = None
241242
242- child_timer = Timer (parent_names = self .parent_names + (name , ))
243+ child_timer = Timer (parent_names = self .parent_names + (name ,))
243244 full_name = " > " .join (child_timer .parent_names )
244245 try :
245246 LOGGER .info (f"Section `{ full_name } ` starts" )
@@ -648,6 +649,16 @@ def print_binary_sizes(pipeline: Pipeline):
648649 LOGGER .info (f"Rustc binary size\n { output .getvalue ()} " )
649650
650651
652+ def print_free_disk_space (pipeline : Pipeline ):
653+ usage = shutil .disk_usage (pipeline .opt_artifacts ())
654+ total = usage .total
655+ used = usage .used
656+ free = usage .free
657+
658+ logging .info (
659+ f"Free disk space: { format_bytes (free )} out of total { format_bytes (total )} ({ (used / total ) * 100 :.2f} % used)" )
660+
661+
651662def execute_build_pipeline (timer : Timer , pipeline : Pipeline , final_build_args : List [str ]):
652663 # Clear and prepare tmp directory
653664 shutil .rmtree (pipeline .opt_artifacts (), ignore_errors = True )
@@ -666,6 +677,7 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, final_build_args: L
666677
667678 with stage1 .section ("Gather profiles" ):
668679 gather_llvm_profiles (pipeline )
680+ print_free_disk_space (pipeline )
669681
670682 clear_llvm_files (pipeline )
671683 final_build_args += [
@@ -683,6 +695,7 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, final_build_args: L
683695
684696 with stage2 .section ("Gather profiles" ):
685697 gather_rustc_profiles (pipeline )
698+ print_free_disk_space (pipeline )
686699
687700 clear_llvm_files (pipeline )
688701 final_build_args += [
@@ -702,6 +715,7 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, final_build_args: L
702715 with stage3 .section ("Gather profiles" ):
703716 gather_llvm_bolt_profiles (pipeline )
704717
718+ print_free_disk_space (pipeline )
705719 clear_llvm_files (pipeline )
706720 final_build_args += [
707721 "--llvm-bolt-profile-use" ,
@@ -733,5 +747,6 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, final_build_args: L
733747 raise e
734748 finally :
735749 timer .print_stats ()
750+ print_free_disk_space (pipeline )
736751
737752 print_binary_sizes (pipeline )
0 commit comments