Include original process name in worker thread name (#14153)
ClosedPublic

Authored by enolan on Sep 20 2017, 5:22 PM.

Details

Summary

Prior to this commit, worker OS thread were renamed to "ghc_worker" when
spawned. This was annoying when reading debugging messages that print the
process name because it doesn't tell you *which* Haskell program is generating
the message.

This commit changes it to "original_process_name:w", truncating the original
name to fit in the kernel buffer if neccesary.

Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
enolan created this revision.Sep 20 2017, 5:22 PM
enolan updated this revision to Diff 14016.Sep 20 2017, 5:52 PM

Fix some OS specific #ifdef stuff.

bgamari added inline comments.Sep 20 2017, 7:59 PM
rts/Task.c
22

It looks like this isn't going to work on Windows; you'll need to guard this on linux_HOST_OS.

475

Is there no way we can do something sensible on Windows?

enolan updated this revision to Diff 14017.Sep 20 2017, 8:22 PM

Fix platform specific issue: use VLA over alloca()

bgamari edited edge metadata.Sep 20 2017, 10:30 PM

Indeed, this looks reasonable to me. Let's see what Harbormaster says.

Phyx added a subscriber: Phyx.Sep 21 2017, 3:00 AM
Phyx added inline comments.
rts/Task.c
475

Yes GetModuleFileName passing a Null for the module gets you the entry point name https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v=vs.85).aspx

enolan added inline comments.Sep 21 2017, 11:48 AM
rts/Task.c
475

On Windows, the threads aren't renamed, so there's nothing to do. If you look in createOSThread in rts/win32/OSThreads.c you can see the name parameter is unused.

Phyx added a comment.Sep 21 2017, 11:58 AM

You can use SetThreadDescription which was introduced in Windows 10. But
anyway it doesn't work now so there's no regression

bgamari accepted this revision.Sep 22 2017, 12:03 PM

Looks good to me. Thanks @enolan!

This revision is now accepted and ready to land.Sep 22 2017, 12:03 PM

How long do the Windows CI builds usually take? It's almost 48 hours old and AFAICT hasn't started yet.

This revision was automatically updated to reflect the committed changes.