mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 19:17:43 +00:00
Rollup merge of #39583 - michaelwoerister:limit-llvm-threads, r=nikomatsakis
back: Limit the number of LLVM worker threads. This should fix issue https://github.com/rust-lang/rust/issues/39568. Also see https://github.com/rust-lang/rust/issues/39280. r? @nikomatsakis
This commit is contained in:
commit
7658921267
@ -27,6 +27,7 @@ use errors::emitter::Emitter;
|
|||||||
use syntax_pos::MultiSpan;
|
use syntax_pos::MultiSpan;
|
||||||
use context::{is_pie_binary, get_reloc_model};
|
use context::{is_pie_binary, get_reloc_model};
|
||||||
|
|
||||||
|
use std::cmp;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@ -754,10 +755,13 @@ pub fn run_passes(sess: &Session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process the work items, optionally using worker threads.
|
// Process the work items, optionally using worker threads.
|
||||||
// NOTE: This code is not really adapted to incremental compilation where
|
// NOTE: We are hardcoding a limit of worker threads for now. With
|
||||||
// the compiler decides the number of codegen units (and will
|
// incremental compilation we can run into situations where we would
|
||||||
// potentially create hundreds of them).
|
// open hundreds of threads otherwise -- which can make things slower
|
||||||
let num_workers = work_items.len() - 1;
|
// if things don't fit into memory anymore, or can cause the compiler
|
||||||
|
// to crash because of too many open file handles. See #39280 for
|
||||||
|
// some discussion on how to improve this in the future.
|
||||||
|
let num_workers = cmp::min(work_items.len() - 1, 32);
|
||||||
if num_workers <= 1 {
|
if num_workers <= 1 {
|
||||||
run_work_singlethreaded(sess, &trans.exported_symbols, work_items);
|
run_work_singlethreaded(sess, &trans.exported_symbols, work_items);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user