File tree 1 file changed +8
-4
lines changed
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;
27
27
use syntax_pos:: MultiSpan ;
28
28
use context:: { is_pie_binary, get_reloc_model} ;
29
29
30
+ use std:: cmp;
30
31
use std:: ffi:: CString ;
31
32
use std:: fs;
32
33
use std:: path:: { Path , PathBuf } ;
@@ -754,10 +755,13 @@ pub fn run_passes(sess: &Session,
754
755
}
755
756
756
757
// 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 ) ;
761
765
if num_workers <= 1 {
762
766
run_work_singlethreaded ( sess, & trans. exported_symbols , work_items) ;
763
767
} else {
You can’t perform that action at this time.
0 commit comments