Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler/rustc_data_structures/src/sync/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ fn par_slice<I: DynSend>(

const MAX_GROUP_COUNT: usize = 128;
let group_size = items.len().div_ceil(MAX_GROUP_COUNT);
let groups = items.chunks_mut(group_size);
let mut groups = items.chunks_mut(group_size);

let Some(first_group) = groups.next() else { return };

// Reverse the order of the later functions since Rayon executes them in reverse
// order when using a single thread. This ensures the execution order matches
Expand All @@ -159,6 +161,11 @@ fn par_slice<I: DynSend>(
}
});
}

// Run the first function without spawning to avoid overwhelming stealing.
for i in first_group.iter_mut() {
guard.run(|| for_each(i));
}
});
}

Expand Down
Loading