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

Tasks launched on foreign threads are getting stickied to them #47756

Closed
vtjnash opened this issue Nov 30, 2022 · 0 comments · Fixed by #48702
Closed

Tasks launched on foreign threads are getting stickied to them #47756

vtjnash opened this issue Nov 30, 2022 · 0 comments · Fixed by #48702
Labels
domain:multithreading Base.Threads and related functionality

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Nov 30, 2022

We are probably noticing the absence of a threadpool here, and so making the new Task sticky, but there is the main task (1) which is also considered a background worker thread:

$ ./julia -t1 -q
julia> threadwork = @cfunction ()->(Threads.@spawn println(Threads.threadid(), " ", current_task().rngState0, " ", current_task().rngState1, " ", current_task().rngState2, " ", current_task().rngState3); Cint(0)) Cint ()
Ptr{Nothing} @0x000000010a7341f0

julia> tid = UInt[0]; @ccall pthread_create(tid::Ptr{UInt}, C_NULL::Ptr{Cvoid}, threadwork::Ptr{Cvoid}, C_NULL::Ptr{Cvoid})::Cint; @ccall pthread_join(tid[]::UInt, C_NULL::Ptr{Cvoid})::Cint
0

julia> Base.Workqueues
2-element Vector{Base.IntrusiveLinkedListSynchronized{Task}}:
 Base.IntrusiveLinkedListSynchronized{Task}(Base.IntrusiveLinkedList{Task}(nothing, nothing), Base.Threads.SpinLock(0))
 Base.IntrusiveLinkedListSynchronized{Task}(Base.IntrusiveLinkedList{Task}(Task (runnable) @0x0000000106fc8160, Task (runnable) @0x0000000106fc8160), Base.Threads.SpinLock(0))

This snippet works if we launch with -t2 or greater

@vtjnash vtjnash added the domain:multithreading Base.Threads and related functionality label Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant