Skip to content

Commit 454f062

Browse files
ChrisDentonrami3l
authored andcommitted
Limit the default number of I/O threads
1 parent b0438a8 commit 454f062

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/diskio/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,15 @@ pub(crate) fn get_executor<'a>(
448448
ram_budget: usize,
449449
process: &Process,
450450
) -> Result<Box<dyn Executor + 'a>> {
451+
// Don't spawn more than this many I/O threads unless the user tells us to.
452+
const DEFAULT_THREAD_LIMIT: usize = 8;
453+
451454
// If this gets lots of use, consider exposing via the config file.
452455
let thread_count = match process.var("RUSTUP_IO_THREADS") {
453-
Err(_) => available_parallelism().map(|p| p.get()).unwrap_or(1),
456+
Err(_) => available_parallelism()
457+
.map(|p| p.get())
458+
.unwrap_or(1)
459+
.min(DEFAULT_THREAD_LIMIT),
454460
Ok(n) => n
455461
.parse::<usize>()
456462
.context("invalid value in RUSTUP_IO_THREADS. Must be a natural number")?,

0 commit comments

Comments
 (0)