JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
44.99k stars 5.42k forks source link

Make JULIA_NUM_THREADS=auto the default #43672

Open jtrakk opened 2 years ago

jtrakk commented 2 years ago

This will help new Julia programmers who don't know about JULIA_NUM_THREADS=auto get fast execution. It also symbolizes how Julia supports the increasing parallelism of modern technical computing. Anybody who needs sequential execution, e.g. for debugging, can use JULIA_NUM_THREADS=1.

ViralBShah commented 2 years ago

At the very least need a good way to get the physical core count as discussed in #43692

fonsp commented 2 years ago

We could use min(1, Sys.CPU_THREADS ÷ 2) as a safe default while waiting on that issue? I also think giving more than one thread by default would be great for new users!

gbaraldi commented 2 years ago

There is also the issue that new cpus have big.Little architectures (M1 mac, 12th gen intel) so we would have to choose either just performance cores (probably the best) or all cores.

lassepe commented 1 month ago

It seems like this issue got stuck. Is there any fundamental downside of having JULIA_NUM_THREADS=auto,auto be the default over the current 1,0? I understand that the auto-detection of the CPU core count is not perfect right now but setting to 1,0 seems to provide a worse default behavior (especially for new users) almost every time (since Threads.@spawn and friends will not warn about having only a single thread so it is just silently refusing the multi-thread.)