Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JULIA_EXCLUSIVE and affinity of sub-processes #42338

Open
tkf opened this issue Sep 22, 2021 · 0 comments
Open

JULIA_EXCLUSIVE and affinity of sub-processes #42338

tkf opened this issue Sep 22, 2021 · 0 comments
Labels
multithreading Base.Threads and related functionality

Comments

@tkf
Copy link
Member

tkf commented Sep 22, 2021

If I start Julia with JULIA_EXCLUSIVE=1 julia1.7 -t4 I get

julia> results = Vector{String}(undef, Threads.nthreads())
       Threads.@threads for i in 1:Threads.nthreads()
           results[i] = read(`sh -c 'taskset -p $$'`, String)
       end
       results
4-element Vector{String}:
 "pid 27240's current affinity mask: 1\n"
 "pid 27237's current affinity mask: 2\n"
 "pid 27239's current affinity mask: 4\n"
 "pid 27238's current affinity mask: 8\n"

This seems to be non-ideal. Programmers ideally don't need to care which tasks run on which thread. So, it's not possible to control the CPU affinity of sub-processes in idiomatic Julia code. If two processes that can run in parallel is happened to be spawned from the same worker thread, they cannot fully utilize CPU resources.

How about saving the affinity at an early phase of the startup (so that configuration of taskset etc. propagates) and then set it in uv_process_options_t when calling uv_spawn?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

No branches or pull requests

1 participant