Unverified Commit d58c9df9 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: remove blocking thread limit to avoid deadlocks (#82961)

### What?

Having a limit of blocking thread can lead to deadlocks the using block_in_place
parent 85ef3638
...@@ -73,6 +73,7 @@ fn init() { ...@@ -73,6 +73,7 @@ fn init() {
use std::{ use std::{
cell::RefCell, cell::RefCell,
panic::{set_hook, take_hook}, panic::{set_hook, take_hook},
thread::available_parallelism,
time::{Duration, Instant}, time::{Duration, Instant},
}; };
...@@ -90,6 +91,8 @@ fn init() { ...@@ -90,6 +91,8 @@ fn init() {
prev_hook(info); prev_hook(info);
})); }));
let worker_threads = available_parallelism().map(|n| n.get()).unwrap_or(1);
let rt = Builder::new_multi_thread() let rt = Builder::new_multi_thread()
.enable_all() .enable_all()
.on_thread_stop(|| { .on_thread_stop(|| {
...@@ -103,6 +106,10 @@ fn init() { ...@@ -103,6 +106,10 @@ fn init() {
} }
}); });
}) })
.worker_threads(worker_threads)
// Avoid a limit on threads to avoid deadlocks due to usage of block_in_place
.max_blocking_threads(usize::MAX - worker_threads)
// Avoid the extra lifo slot to avoid stalling tasks when doing cpu-heavy work
.disable_lifo_slot() .disable_lifo_slot()
.build() .build()
.unwrap(); .unwrap();
......
#![feature(future_join)] #![feature(future_join)]
#![feature(min_specialization)] #![feature(min_specialization)]
use std::{cell::RefCell, path::Path, time::Instant}; use std::{cell::RefCell, path::Path, thread::available_parallelism, time::Instant};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::Parser; use clap::Parser;
...@@ -42,6 +42,11 @@ fn main() { ...@@ -42,6 +42,11 @@ fn main() {
}); });
}); });
let worker_threads = available_parallelism().map(|n| n.get()).unwrap_or(1);
rt.worker_threads(worker_threads);
rt.max_blocking_threads(usize::MAX - worker_threads);
#[cfg(not(codspeed))] #[cfg(not(codspeed))]
rt.disable_lifo_slot(); rt.disable_lifo_slot();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment