Setting RTS thread names useful?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting RTS thread names useful?

Viktor Dukhovni
The RTS sets thread names on Linux, but not other POSIX platforms.
FreeBSD has the requesite functionality, and the patch below can
enable it.  Not sure whether this is in fact useful, since all
threads would get the same name ("ghc_worker"):

diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index 7dcf0eed15..9d2d9a897e 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -139,6 +139,9 @@ createOSThread (OSThreadId* pId, char *name STG_UNUSED,
     pthread_detach(*pId);
 #if defined(HAVE_PTHREAD_SETNAME_NP)
     pthread_setname_np(*pId, name);
+#elif defined(freebsd_HOST_OS)
+    /* Since FreeBSD 5.1 */
+    pthread_set_name_np(*pId, name);
 #endif
   }
   return result;

On Linux the thread name is taken from the static variable
"program_invocation_short_name", which is again the same
for all threads of each program, but is not globally the
same. FreeBSD could get the same result with getprogname(3).

The question still remains as to whether setting such thread
names is useful or pointless...

--
        Viktor.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Setting RTS thread names useful?

Joachim Durchholz
Am 29.08.2018 um 01:36 schrieb Viktor Dukhovni:
> The question still remains as to whether setting such thread
> names is useful or pointless...

Non-Haskell code in the program might create threads, too.
The name would help distinguishing them from Haskell's own threads.

It's admittedly not a common scenario, but there it is :-)
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.