-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
make thread 1 interactive when there is an interactive pool, so it can run the event loop #49094
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add an API at the same time for people to enumerate all worker thread ids (to keep the @threads
macro working correctly)?
Thanks for this fix! I've been meaning to dig into why our interactive thread isn't being very interactive... |
3428071
to
c374808
Compare
Ok I have implemented all of the above. I wasn't sure we wanted to always have 2 threadpools but I guess there is no harm. The new function is provisionally named |
Removing |
Bump |
…n run the event loop
e97a32f
to
20fa695
Compare
…n run the event loop (JuliaLang#49094)
Since #49094, the docstring of `nthreads` has been incorrect. It currently states that > The threads in default have id numbers `1:nthreads(:default)`. whereas that is no longer true: ```julia julia> filter(i -> Threads.threadpool(i) == :interactive, 1:Threads.maxthreadid()) 3-element Vector{Int64}: 1 2 3 julia> filter(i -> Threads.threadpool(i) == :default, 1:Threads.maxthreadid()) 6-element Vector{Int64}: 4 5 6 7 8 9 ```
Since #49094, the docstring of `nthreads` has been incorrect. It currently states that > The threads in default have id numbers `1:nthreads(:default)`. whereas that is no longer true: ```julia julia> filter(i -> Threads.threadpool(i) == :interactive, 1:Threads.maxthreadid()) 3-element Vector{Int64}: 1 2 3 julia> filter(i -> Threads.threadpool(i) == :default, 1:Threads.maxthreadid()) 6-element Vector{Int64}: 4 5 6 7 8 9 ``` (cherry picked from commit 95ae27f)
Since JuliaLang#49094, the docstring of `nthreads` has been incorrect. It currently states that > The threads in default have id numbers `1:nthreads(:default)`. whereas that is no longer true: ```julia julia> filter(i -> Threads.threadpool(i) == :interactive, 1:Threads.maxthreadid()) 3-element Vector{Int64}: 1 2 3 julia> filter(i -> Threads.threadpool(i) == :default, 1:Threads.maxthreadid()) 6-element Vector{Int64}: 4 5 6 7 8 9 ``` (cherry picked from commit 95ae27f)
There is a major problem preventing interactive threads from working well, which is that outside an
@threads
region thread 1 is still the only one allowed to run the event loop. Responding to events is kind of the whole deal with interactive threads, so they need to be able to enter the event loop. We can't fully fix this until_threadedregion
is finally removed. So to make interactive threads work in the meantime, this PR proposes making the interactive pool the first one, so thread 1 is interactive. For code like the following:this PR takes it from not working to working.