... | ... | @@ -7,12 +7,14 @@ This wiki page is for the project by Karolis Velicka \<karolis.velicka at google |
|
|
This wiki page documents my current understanding of the system, plans for improving it, progress reports and assorted notes from meting that are relevant to the topic.
|
|
|
|
|
|
|
|
|
In case you find some flaws in my understanding, something that you disagree with or statements that are outright wrong, please do contact me.
|
|
|
In case you find some flaws in my understanding, something that you disagree with or statements that are outright wrong, please do contact me. Any other contributions/advice/edits are very welcome!
|
|
|
|
|
|
## Goals
|
|
|
|
|
|
### Initial Goals
|
|
|
|
|
|
Some guideline goals for the project, as set out by [ Duncan Coutts](http://www.well-typed.com/people/duncan):
|
|
|
|
|
|
As set out by [ Duncan Coutts](http://www.well-typed.com/people/duncan):
|
|
|
|
|
|
|
|
|
In the RTS:
|
... | ... | @@ -36,3 +38,118 @@ Basic demo of live monitoring using above new features: |
|
|
- demo CLI 'monitored' prog that uses the RTS APIs to direct its eventlog to a local FIFO, emit the various sync events. Perhaps interactive to exercise turning the eventlog on/off, enabling/disabling various event classes.
|
|
|
- demo CLI 'monitoring' prog that uses the new ghc-events lib to start reading and decoding the event stream.
|
|
|
- Proof-of-concept EKG-like functionality would be to emit mem/GC summary stats lines every second.
|
|
|
|
|
|
### Goals that have been added later
|
|
|
|
|
|
- Move the link between RTS and ghc-events into a separate library where both a client-server (see below) and file based implementations of the "link" could be stored.
|
|
|
|
|
|
## Notes from meetings
|
|
|
|
|
|
|
|
|
Some are merged with other points and therefore are removed from this list
|
|
|
|
|
|
- In current state, RTS writes to the eventlog asynchronously.
|
|
|
- Need a new module in RTS for start/stop event logging
|
|
|
- RTS and GHC.RTS talk together via foreign ccalls
|
|
|
- Start/stop of logging would need to stop the HECs for sync. Need to measure the performance of this
|
|
|
- During this we need to traverse threads in struct generation_, they are in global variable called generations. Also look into StgTSO (thread structures)
|
|
|
- Flushing only needs to flush inactive buffers (that are also not empty)
|
|
|
- Possibly add some GC events (some are currently in tracegc at the moment):
|
|
|
|
|
|
- heap size
|
|
|
- heap live
|
|
|
- High level API for time sorted lazy list of events
|
|
|
|
|
|
|
|
|
Q&A from the meeting
|
|
|
|
|
|
- Does RTS broadcast all the time or on demand?
|
|
|
|
|
|
- On demand, after a client connects
|
|
|
- What would the connection be for live eventlog
|
|
|
|
|
|
- Sockets seem to be appropriate for the job
|
|
|
- Which tasks are priorities?
|
|
|
|
|
|
- Sliped my mind. TODO
|
|
|
|
|
|
## Discussed APIs
|
|
|
|
|
|
### ghc-events
|
|
|
|
|
|
```wiki
|
|
|
-- high level lazy API (based on chunked input underneath)
|
|
|
streamEvents :: ByteString.Lazy -> [CapEvent]
|
|
|
|
|
|
-- returns a list of fully parsed events ant the remaining ByteString
|
|
|
parse :: ByteString -> ([Event], ByteString)
|
|
|
-- alternatively parse one event at a time and return the rest
|
|
|
parse :: ByteString -> (Event, ByteString)
|
|
|
|
|
|
-- a parser instance that may be used
|
|
|
Parser (Event, Bytestring)
|
|
|
-- could be created by
|
|
|
p = do
|
|
|
e <- parseEvent
|
|
|
b <- takeRemainingInput
|
|
|
return (e,b)
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
### RTS
|
|
|
|
|
|
|
|
|
C side:
|
|
|
|
|
|
```wiki
|
|
|
// idea is to use a generic fd so that both file-based and
|
|
|
// socket-based connection would be available
|
|
|
initEventLogging(fd);
|
|
|
|
|
|
// flush the buffer for a Capability after ms milliseconds of inactivity
|
|
|
flushEventLog(int ms);
|
|
|
|
|
|
stopEventLogging();
|
|
|
|
|
|
// Current idea is to use bit fields for this
|
|
|
enableEvents(EventClasses);
|
|
|
disableEvents(EventClasses);
|
|
|
```
|
|
|
|
|
|
|
|
|
ghc/base side:
|
|
|
|
|
|
```wiki
|
|
|
startEventLogging :: Fd -> IO()
|
|
|
stopEventLogging :: IO()
|
|
|
-- <...>
|
|
|
-- equivalent to functions on C side
|
|
|
```
|
|
|
|
|
|
## Misc
|
|
|
|
|
|
|
|
|
example log servers
|
|
|
|
|
|
|
|
|
C:
|
|
|
|
|
|
```wiki
|
|
|
logserver.c
|
|
|
s = socket()
|
|
|
listen(s)
|
|
|
t = accept(s)
|
|
|
initEventLogging(t)
|
|
|
```
|
|
|
|
|
|
|
|
|
Haskell:
|
|
|
|
|
|
```wiki
|
|
|
logserver.hs
|
|
|
s <- socket
|
|
|
listen
|
|
|
t <- accept s
|
|
|
startEventLogging t
|
|
|
``` |
|
|
\ No newline at end of file |