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() {
use std::{
cell::RefCell,
panic::{set_hook, take_hook},
thread::available_parallelism,
time::{Duration, Instant},
};
......@@ -90,6 +91,8 @@ fn init() {
prev_hook(info);
}));
let worker_threads = available_parallelism().map(|n| n.get()).unwrap_or(1);
let rt = Builder::new_multi_thread()
.enable_all()
.on_thread_stop(|| {
......@@ -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()
.build()
.unwrap();
......
#![feature(future_join)]
#![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 clap::Parser;
......@@ -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))]
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