Understanding use of interactive thread pool

Hello,

I am trying to understand when the “interactive” thread pool is used vs when the “default” thread pool is used. My expectation is that the “default” thread pool is used unless we explicitly ask for the interactive thread pool. Indeed, the documentation seems to indicate that this is the case. But, the following code,

julia -t 1,1 -e 'print(stdout, "$(Threads.threadpool())\n")'

gives,

interactive

It is surprising to me that by default the interactive thread is used. I can work-a-round this by doing:

julia -t 1,1 -e 'wait(Threads.@spawn print(stdout, "$(Threads.threadpool())\n"))'

but, it seems that this should not be needed, it doesn’t match with the documentation, and this work-a-round is often inconvenient.

I am using Julia 1.10, and Ubuntu 22.04. Any thoughts? Am I doing something wrong, or is the behavior wrong, or is the documentation incorrect?

I identified this problem while trying to run some code in an interactive thread, and noticing that it did not appear to be interactive :slight_smile: .

Many thanks!

Sam

1 Like

Threads that you spawn are all in the :default thread pool by default. The thread that you work on in the interactive REPL is, of course, an interactive thread.

Hi @carstenbauer

Thanks so much for your response. What you say makes sense, but it doesn’t seem to match what I observe. For example, when I try the following code:

julia -t 1,1 -e 'Threads.threadid() in Threads.threadpooltids(:interactive) ? println("interactive") : println("default"); println(isinteractive())'

I see,

interactive
false

The first line in the output indiicates that we are using the interactive thread, and the second line is just to confrim that we are not running in interactive mode.

Can I trouble you to try running the same code. Perhaps there is something wrong with my setup.

Many thanks!

Turns out the documentation is wrong.

julia -t 3 -E 'Threads.threadpool()'
:default
julia -t 3,1 -E 'Threads.threadpool()'
:interactive

This change in behavior is surprising to me and the latter case is in contrast to what the documentation says.

Might, perhaps, be related to the fact that the ordering of thread ids changed (kind of last minute) from “default first, then interactive” to “interactive first, then default”. Would you mind filing an issue on github?

2 Likes

My first reply was (partially) incorrect, as demonstrated in my post above. I’ve striked out the corresponding part.

1 Like

Thanks @carstenbauer. Here is the GitHub issue: Surprising behavior for default/interactive thread pools · Issue #53217 · JuliaLang/julia (github.com)

1 Like