Adding uv_thread_name + adding a way to name worker threads + query number of workers

Skip to first unread message

Benjamin Sergeant

Mar 4, 2021, 1:23:01 PM3/4/21
to libuv
Hi there,

We have a tiny patch that we feel would better live upstream, so that we can name lib worker threads, which is helpful when debugging a program with a lot of threads (in gdb, or with perf top etc...).

We use pthread_setname_np for that which only works on unix but it can be made portable relatively easily (I have a wrapper here that works for windows/macOS/freebsd/linux at. least). If we expose a set api, we probably need a get api to be well behaved.

We use it to give the same name to all the worker threads but we could probably add a _1, _2 et.... for each of them. Or maybe we don't even need to do that, and libuv could name those threads itself ?

Also we have a function to query how many idle threads there are (uv_queue_work_idle_threads).

How does the community feel about those ? Should we start making PR for that ?

Thanks !
- Benjamin
Reply all
Reply to author
0 new messages