Skip to content

Commit d3564d7

Browse files
Auto merge of #142247 - zetanumbers:remove-parallel-deadlock-detection, r=<try>
Remove deadlock detection for benchmarking
2 parents 14863ea + 1a40227 commit d3564d7

File tree

9 files changed

+20
-381
lines changed

9 files changed

+20
-381
lines changed

Cargo.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,8 +3179,7 @@ dependencies = [
31793179
[[package]]
31803180
name = "rustc-rayon-core"
31813181
version = "0.5.1"
3182-
source = "registry+https://github.com/rust-lang/crates.io-index"
3183-
checksum = "2f42932dcd3bcbe484b38a3ccf79b7906fac41c02d408b5b1bac26da3416efdb"
3182+
source = "git+https://github.com/zetanumbers/rayon?branch=rustc-remove-deadlock-detection#3b8d9c138ab70138c2016d19fbb2801a372614f6"
31843183
dependencies = [
31853184
"crossbeam-deque",
31863185
"crossbeam-utils",
@@ -4344,7 +4343,6 @@ version = "0.0.0"
43444343
dependencies = [
43454344
"hashbrown",
43464345
"parking_lot",
4347-
"rustc-rayon-core",
43484346
"rustc_abi",
43494347
"rustc_ast",
43504348
"rustc_attr_data_structures",
@@ -6599,3 +6597,8 @@ dependencies = [
65996597
"quote",
66006598
"syn 2.0.101",
66016599
]
6600+
6601+
[[patch.unused]]
6602+
name = "rustc-rayon"
6603+
version = "0.5.1"
6604+
source = "git+https://github.com/zetanumbers/rayon?branch=rustc-remove-deadlock-detection#3b8d9c138ab70138c2016d19fbb2801a372614f6"

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ exclude = [
6060
"obj",
6161
]
6262

63+
[patch.crates-io]
64+
rustc-rayon = { git = "https://github.com/zetanumbers/rayon", branch = "rustc-remove-deadlock-detection" }
65+
rustc-rayon-core = { git = "https://github.com/zetanumbers/rayon", branch = "rustc-remove-deadlock-detection" }
66+
6367
[profile.release.package.rustc-rayon-core]
6468
# The rustc fork of Rayon has deadlock detection code which intermittently
6569
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)

compiler/rustc_interface/src/util.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_session::{EarlyDiagCtxt, Session, filesearch};
1818
use rustc_span::edit_distance::find_best_match_for_name;
1919
use rustc_span::edition::Edition;
2020
use rustc_span::source_map::SourceMapInputs;
21-
use rustc_span::{SessionGlobals, Symbol, sym};
21+
use rustc_span::{Symbol, sym};
2222
use rustc_target::spec::Target;
2323
use tracing::info;
2424

@@ -174,13 +174,7 @@ pub(crate) fn run_in_thread_pool_with_globals<
174174
sm_inputs: SourceMapInputs,
175175
f: F,
176176
) -> R {
177-
use std::process;
178-
179-
use rustc_data_structures::defer;
180177
use rustc_data_structures::sync::FromDyn;
181-
use rustc_middle::ty::tls;
182-
use rustc_query_impl::QueryCtxt;
183-
use rustc_query_system::query::{QueryContext, break_query_cycles};
184178

185179
let thread_stack_size = init_stack_size(thread_builder_diag);
186180

@@ -202,7 +196,6 @@ pub(crate) fn run_in_thread_pool_with_globals<
202196
}
203197

204198
let current_gcx = FromDyn::from(CurrentGcx::new());
205-
let current_gcx2 = current_gcx.clone();
206199

207200
let proxy = Proxy::new();
208201

@@ -213,46 +206,6 @@ pub(crate) fn run_in_thread_pool_with_globals<
213206
.acquire_thread_handler(move || proxy_.acquire_thread())
214207
.release_thread_handler(move || proxy__.release_thread())
215208
.num_threads(threads)
216-
.deadlock_handler(move || {
217-
// On deadlock, creates a new thread and forwards information in thread
218-
// locals to it. The new thread runs the deadlock handler.
219-
220-
let current_gcx2 = current_gcx2.clone();
221-
let registry = rayon_core::Registry::current();
222-
let session_globals = rustc_span::with_session_globals(|session_globals| {
223-
session_globals as *const SessionGlobals as usize
224-
});
225-
thread::Builder::new()
226-
.name("rustc query cycle handler".to_string())
227-
.spawn(move || {
228-
let on_panic = defer(|| {
229-
eprintln!("internal compiler error: query cycle handler thread panicked, aborting process");
230-
// We need to abort here as we failed to resolve the deadlock,
231-
// otherwise the compiler could just hang,
232-
process::abort();
233-
});
234-
235-
// Get a `GlobalCtxt` reference from `CurrentGcx` as we cannot rely on having a
236-
// `TyCtxt` TLS reference here.
237-
current_gcx2.access(|gcx| {
238-
tls::enter_context(&tls::ImplicitCtxt::new(gcx), || {
239-
tls::with(|tcx| {
240-
// Accessing session globals is sound as they outlive `GlobalCtxt`.
241-
// They are needed to hash query keys containing spans or symbols.
242-
let query_map = rustc_span::set_session_globals_then(unsafe { &*(session_globals as *const SessionGlobals) }, || {
243-
// Ensure there was no errors collecting all active jobs.
244-
// We need the complete map to ensure we find a cycle to break.
245-
QueryCtxt::new(tcx).collect_active_jobs().ok().expect("failed to collect active queries in deadlock handler")
246-
});
247-
break_query_cycles(query_map, &registry);
248-
})
249-
})
250-
});
251-
252-
on_panic.disable();
253-
})
254-
.unwrap();
255-
})
256209
.stack_size(thread_stack_size);
257210

258211
// We create the session globals on the main thread, then create the thread

compiler/rustc_query_system/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
parking_lot = "0.12"
9-
rustc-rayon-core = { version = "0.5.0" }
109
rustc_abi = { path = "../rustc_abi" }
1110
rustc_ast = { path = "../rustc_ast" }
1211
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }

0 commit comments

Comments
 (0)