Skip to content

Commit

Permalink
Rollup merge of rust-lang#39583 - michaelwoerister:limit-llvm-threads…
Browse files Browse the repository at this point in the history
…, r=nikomatsakis

back: Limit the number of LLVM worker threads.

This should fix issue rust-lang#39568.
Also see rust-lang#39280.

r? @nikomatsakis
  • Loading branch information
frewsxcv authored Feb 8, 2017
2 parents 944933e + fa0a728 commit 7658921
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use errors::emitter::Emitter;
use syntax_pos::MultiSpan;
use context::{is_pie_binary, get_reloc_model};

use std::cmp;
use std::ffi::CString;
use std::fs;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -754,10 +755,13 @@ pub fn run_passes(sess: &Session,
}

// Process the work items, optionally using worker threads.
// NOTE: This code is not really adapted to incremental compilation where
// the compiler decides the number of codegen units (and will
// potentially create hundreds of them).
let num_workers = work_items.len() - 1;
// NOTE: We are hardcoding a limit of worker threads for now. With
// incremental compilation we can run into situations where we would
// open hundreds of threads otherwise -- which can make things slower
// 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 {
run_work_singlethreaded(sess, &trans.exported_symbols, work_items);
} else {
Expand Down

0 comments on commit 7658921

Please sign in to comment.