Skip to content

Commit f5fe433

Browse files
committed
Simplify jl_effective_threads implementation
Take the minimum of `jl_cpu_threads` and `uv_available_parallelism` on all platforms.
1 parent 427bc6f commit f5fe433

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/sys.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,10 @@ JL_DLLEXPORT int jl_cpu_threads(void) JL_NOTSAFEPOINT
478478

479479
JL_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.
486-
int cpu = jl_cpu_threads();
487-
return n < cpu ? n : cpu;
488-
#else
489-
return n;
490-
#endif
481+
// We want the more conservative estimate of the two.
482+
int cpu_threads = jl_cpu_threads();
483+
int available_parallelism = uv_available_parallelism();
484+
return available_parallelism < cpu_threads ? available_parallelism : cpu_threads;
491485
}
492486

493487

0 commit comments

Comments
 (0)