-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
Sorry, this is a full Julia report, but it involves only libuv functions. The problem is that on Windows, but not on Linux, uv_available_parallelism doesn't respect process affinity, contrary to uv_thread_getaffinity, returning total number of logical threads available in the system:
julia> run(setcpuaffinity(`$(Base.julia_cmd()) -L $(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test", "print_process_affinity.jl")) -e '@show(length(uv_thread_getaffinity())); @show(@ccall uv_available_parallelism()::Cint); @show(Sys.CPU_THREADS)'`, 1:2));
length(uv_thread_getaffinity()) = 2
#= none:1 =# @ccall(uv_available_parallelism()::Cint) = 4
Sys.CPU_THREADS = 4I'm using setcpuaffinity to set the affinity of the process and limit it two cores, I'm loading the test/print_process_affinity.jl script which defines a small wrapper around uv_thread_getaffinity, and I'm also printing Julia's Sys.CPU_THREAD to show the total number of logical threads on the system.
On Linux I get
julia> run(setcpuaffinity(`$(Base.julia_cmd()) -L $(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test", "print_process_affinity.jl")) -e '@show(length(uv_thread_getaffinity())); @show(@ccall uv_available_parallelism()::Cint); @show(Sys.CPU_THREADS)'`, 1:2));
length(uv_thread_getaffinity()) = 2
#= none:1 =# @ccall(uv_available_parallelism()::Cint) = 2
Sys.CPU_THREADS = 32as expected.
Current build of libuv used in Julia is based on libuv v1.48.0. CC: @vtjnash.