[Haskell-cafe] Setting RTS thread names useful?
Viktor Dukhovni
ietf-dane at dukhovni.org
Tue Aug 28 23:36:32 UTC 2018
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.
More information about the Haskell-Cafe
mailing list