wavewave / ghc-eventlog-socket

Pipe the GHC eventlog stream to a UNIX domain socket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  • access control?
  • support only Unix domain sockets or also tcp/ip?
  • do we want to support multiple consumers?
  • what should happen when a consumer disconnects? we could either
    • currently we just pause the eventlog until a new consumer shows up
    • close the socket and stop streaming
    • pause the program until a new consumer shows up
    • kill the program

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

About

Pipe the GHC eventlog stream to a UNIX domain socket

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C 92.8%Language:Haskell 7.2%