File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -478,25 +478,16 @@ JL_DLLEXPORT int jl_cpu_threads(void) JL_NOTSAFEPOINT
478478
479479JL_DLLEXPORT int jl_effective_threads (void ) JL_NOTSAFEPOINT
480480{
481+ int n = uv_available_parallelism ();
482+ #if defined(__APPLE__ ) && defined(_CPU_AARCH64_ )
483+ // Only on Apple Silicon we don't just return `uv_available_parallelism` because it may
484+ // be larger than `jl_cpu_threads` (which asks for the performance cores only), and we
485+ // want the more conservative estimate of the two.
481486 int cpu = jl_cpu_threads ();
482- int masksize = uv_cpumask_size ();
483- if (masksize < 0 || jl_running_under_rr (0 ))
484- return cpu ;
485- uv_thread_t tid = uv_thread_self ();
486- char * cpumask = (char * )calloc (masksize , sizeof (char ));
487- int err = uv_thread_getaffinity (& tid , cpumask , masksize );
488- if (err ) {
489- free (cpumask );
490- jl_safe_printf ("WARNING: failed to get thread affinity (%s %d)\n" , uv_err_name (err ),
491- err );
492- return cpu ;
493- }
494- int n = 0 ;
495- for (size_t i = 0 ; i < masksize ; i ++ ) {
496- n += cpumask [i ];
497- }
498- free (cpumask );
499487 return n < cpu ? n : cpu ;
488+ #else
489+ return n ;
490+ #endif
500491}
501492
502493
You can’t perform that action at this time.
0 commit comments