Does stdlib network sockets use only first thread?

Heyo, I’m one of the CImGui maintainers :slight_smile: What you’re seeing is expected because by default the libuv event loop only runs on thread 1. This is documented in the render() docs: Backends · CImGui.jl

In particular:

spawn::Union{Bool, Integer, Symbol}=1: How/where to spawn the renderloop. It defaults to thread 1 for safety, but note that currently Julia also uses thread 1 to run the libuv event loop: #50643. The renderloop does yield() on each iteration but it’s still likely to hog thread 1 which may cause libuv things like task switching to become slower. In most cases this is unlikely to be a problem, but keep it in mind if you observe IO/task heavy things being slower than you’d expect.

The main reason for pinning is to prevent task migration from one thread to another, that would break all sorts of things. The reason for pinning to thread 1 is only because that’s what GLFW recommends, but (AFAIU) that’s mostly because of OSX: Multithreading GLFW? - #5 by elmindreda - support - GLFW

TL;DR: if you’re running on Linux you can choose any thread you like (I would suggest one in the interactive threadpool). A different thread might work on Windows and will likely not on OSX (but I’ve never tried it so who knows).

1 Like