@@ -39,6 +39,7 @@ pub fn run_benchmarks<P: AsRef<Path>>(
3939
4040 // 2. Generate codspeed runners, build binaries, and execute them
4141 let templater = Templater :: new ( ) ;
42+ let mut threads = Vec :: with_capacity ( packages. len ( ) ) ;
4243 for package in & packages {
4344 info ! ( "Generating custom runner for package: {}" , package. name) ;
4445 let ctx = templater. run ( package, & profile_dir) ?;
@@ -65,15 +66,23 @@ pub fn run_benchmarks<P: AsRef<Path>>(
6566 error ! ( "Failed to run benchmarks for {}: {error}" , package. name) ;
6667 continue ;
6768 }
69+
70+ // Collect the results in a new thread, to avoid blocking the main thread at the end. The
71+ // conversions and computations can take a while when we have a lot of iterations.
72+ let profile_dir = profile_dir. as_ref ( ) . to_path_buf ( ) ;
73+ threads. push ( std:: thread:: spawn ( move || {
74+ collect_walltime_results ( profile_dir. as_ref ( ) ) . unwrap ( ) ;
75+ } ) ) ;
6876 } else {
6977 info ! ( "Skipping benchmark execution (dry-run mode)" ) ;
7078 }
7179 }
7280
73- // 3. Collect the results
74- if !cli. dry_run {
75- collect_walltime_results ( profile_dir. as_ref ( ) ) ?;
76- }
81+ // Wait for all result collection threads to finish
82+ threads. into_iter ( ) . for_each ( |t| {
83+ t. join ( )
84+ . expect ( "Failed to join collect_walltime_results thread" )
85+ } ) ;
7786
7887 Ok ( ( ) )
7988}
@@ -90,11 +99,6 @@ pub fn collect_walltime_results(profile_dir: &Path) -> anyhow::Result<()> {
9099 . push ( walltime_result) ;
91100 }
92101
93- // Remove raw results directory after processing to save space
94- if raw_results_dir. exists ( ) {
95- std:: fs:: remove_dir_all ( & raw_results_dir) ?;
96- }
97-
98102 for ( pid, walltime_benchmarks) in benchmarks_by_pid {
99103 let creator = results:: walltime_results:: Creator {
100104 name : "codspeed-go" . into ( ) ,
0 commit comments