Skip to content

Commit 7162208

Browse files
committed
Auto merge of #154419 - zetanumbers:take-first-group, r=<try>
Take first task group for further execution
2 parents cf7da0b + 576a727 commit 7162208

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

compiler/rustc_data_structures/src/sync/parallel.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)