Julia irresponsive with threads=auto and using ImageView

Hello
I have noticed that with the switch --threads=auto while starting Julia and using package ImageView the system has trouble responding to keyboard hits. If I try using up, down, left or right arrows on my keyboard the result is completely unpredictable. I have to wait a little bit before hitting keys, otherwise the display on the screen is not proper. About anything is problematic. I cannot paste a command neither it’s too fast for julia. Even a simple exit() take a while to finalize and exit julia.

Weirdest of all: I have the feeling that of I type something in another window totally unrelated to the window where I run julia (like typing this issue in the browser for instance) helps julia. It looks like the multithread option corrupts the interraction with the keyboard. I don’t see any abnormal CPU/RAM usage when julia hangs like that.

I don’t have a packages in the project and I only need load ImageView to get the strange behaviour.

I am using Julia 1.11.3 on Windows 11.
I have the same problem regardless if it is the standard cmd window or the Powershell window.

Damn it! I have the same problem with Ubuntu 24.10.

1 Like

This is probably REPL locks up after `using Gtk4` in julia 1.11 with multiple threads · Issue #78 · JuliaGtk/Gtk4.jl · GitHub. Does it happen if you call julia with --threads=auto,1?

3 Likes

No. It looks good in that situation.

Here --threads==auto allows Julia to run on all the threads available in cpu and hence screen freezes. While --threads==auto,1 keeps 1 thread free for other processes and assigns other threads for Julia use. This is why it does not hang cpu in this case. :sweat_smile:

4 Likes

@raman_kumar

Thanks for the information Raman. However, I am a bit confuse. If I do

julia --threads=auto,1
              _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.3 (2025-01-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Base.Threads

julia> Threads.nthreads()
20

As you can see I have 20 threads available. Given that I have 20 cores in my CPU, it seems that all are available. So, where is the thread free for other processes? Further, I don’t understand what you mean by “other processes”. And when you say the remaining ones are for Julia. I understand that they are available to me for use of my Julia programs. That’s what Threads.nthreads()seems to indicate.
Could you please elaborate a bit more on what the =yes,1 value does?

By the way I use =yes,1 NOT ==yes,1. Does that make a difference? is it equivalent.

Thanks a lot for your time.

1 Like

You can read more about the two thread pools here: Multi-Threading · The Julia Language. The argument --threads=n,m denotes n threads in the :default thread pool and m threads in the :interactive thread pool. (Either or both of m and n can be "auto" to tell Julia to make a choice informed by the hardware you’re running on.)

If you only specify --threads=n you get n threads in the :default pool and zero threads in the :interactive pool. In other words, the difference between the two cases you’re considering is whether or not you have a thread reserved for interactive use.

2 Likes