File tree Expand file tree Collapse file tree
compiler/rustc_data_structures/src/sync Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,9 @@ fn par_slice<I: DynSend>(
145145
146146 const MAX_GROUP_COUNT : usize = 128 ;
147147 let group_size = items. len ( ) . div_ceil ( MAX_GROUP_COUNT ) ;
148- let groups = items. chunks_mut ( group_size) ;
148+ let mut groups = items. chunks_mut ( group_size) ;
149+
150+ let Some ( first_group) = groups. next ( ) else { return } ;
149151
150152 // Reverse the order of the later functions since Rayon executes them in reverse
151153 // order when using a single thread. This ensures the execution order matches
@@ -159,6 +161,11 @@ fn par_slice<I: DynSend>(
159161 }
160162 } ) ;
161163 }
164+
165+ // Run the first function without spawning to avoid overwhelming stealing.
166+ for i in first_group. iter_mut ( ) {
167+ guard. run ( || for_each ( i) ) ;
168+ }
162169 } ) ;
163170}
164171
You can’t perform that action at this time.
0 commit comments