Setting RTS thread names useful?

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.

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 :-)
participants (2)
-
Joachim Durchholz
-
Viktor Dukhovni