well-typed / ghc-eventlog-socket

Pipe the GHC eventlog stream to a UNIX domain socket
BSD 3-Clause "New" or "Revised" License
15 stars 6 forks source link

eventlog-socket

A library to send GHC's eventlog stream over a Unix domain socket.

In your application

executable MyProgram
   ...
   build-depends: eventlog-socket
   ghc-options: -eventlog
import qualified GHC.Eventlog.Socket

main :: IO ()
main = do
    ...
    GHC.Eventlog.Socket.start "/tmp/my-program.eventlog.sock"
    ...
$ ./MyProgram +RTS -l &
$ nc -U /tmp/my-program.eventlog.sock > my-program.eventlog

This is a prototype to play around with the possibility of using the eventlog for realtime profiling and performance analysis. There are still numerous open questions:

Development

As the most code is C using following line will speedup development considerably (change your GHC installation path accordingly):

gcc -c -Iinclude -I/opt/ghc/9.0.1/lib/ghc-9.0.1/include -o eventlog_socket.o cbits/eventlog_socket.c
gcc -c -Iinclude -I/opt/ghc/9.2.0.20210821/lib/ghc-9.2.0.20210821/include -o eventlog_socket.o cbits/eventlog_socket.c