File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -681,6 +681,7 @@ void jl_init_threading(void)
681
681
}
682
682
}
683
683
684
+ int cpu = jl_cpu_threads ();
684
685
jl_n_markthreads = jl_options .nmarkthreads - 1 ;
685
686
jl_n_sweepthreads = jl_options .nsweepthreads ;
686
687
if (jl_n_markthreads == -1 ) { // --gcthreads not specified
@@ -709,8 +710,20 @@ void jl_init_threading(void)
709
710
else {
710
711
jl_n_markthreads = (nthreads / 2 ) - 1 ;
711
712
}
713
+ // if `--gcthreads` or ENV[NUM_GCTHREADS_NAME] was not specified,
714
+ // cap the number of threads that may run the mark phase to
715
+ // the number of CPU cores
716
+ if (jl_n_markthreads + 1 >= cpu ) {
717
+ jl_n_markthreads = cpu - 1 ;
718
+ }
712
719
}
713
720
}
721
+ // warn the user if they try to run with a number
722
+ // of GC threads which is larger than the number
723
+ // of physical cores
724
+ if (jl_n_markthreads + 1 > cpu ) {
725
+ jl_safe_printf ("WARNING: running Julia with %d GC threads on %d CPU cores\n" , jl_n_markthreads + 1 , cpu );
726
+ }
714
727
int16_t ngcthreads = jl_n_markthreads + jl_n_sweepthreads ;
715
728
716
729
jl_all_tls_states_size = nthreads + nthreadsi + ngcthreads ;
You can’t perform that action at this time.
0 commit comments