File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ use errors::emitter::Emitter;
2727use syntax_pos:: MultiSpan ;
2828use context:: { is_pie_binary, get_reloc_model} ;
2929
30+ use std:: cmp;
3031use std:: ffi:: CString ;
3132use std:: fs;
3233use std:: path:: { Path , PathBuf } ;
@@ -754,10 +755,13 @@ pub fn run_passes(sess: &Session,
754755 }
755756
756757 // Process the work items, optionally using worker threads.
757- // NOTE: This code is not really adapted to incremental compilation where
758- // the compiler decides the number of codegen units (and will
759- // potentially create hundreds of them).
760- let num_workers = work_items. len ( ) - 1 ;
758+ // NOTE: We are hardcoding a limit of worker threads for now. With
759+ // incremental compilation we can run into situations where we would
760+ // open hundreds of threads otherwise -- which can make things slower
761+ // if things don't fit into memory anymore, or can cause the compiler
762+ // to crash because of too many open file handles. See #39280 for
763+ // some discussion on how to improve this in the future.
764+ let num_workers = cmp:: min ( work_items. len ( ) - 1 , 32 ) ;
761765 if num_workers <= 1 {
762766 run_work_singlethreaded ( sess, & trans. exported_symbols , work_items) ;
763767 } else {
You can’t perform that action at this time.
0 commit comments