Skip to content

Commit

Permalink
Merge pull request #60 from bgamari/nonmoving-gc
Browse files Browse the repository at this point in the history
Support for non-moving GC events
  • Loading branch information
maoe authored Apr 24, 2020
2 parents fc02061 + 149b9ca commit e811ce7
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ghc-events.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ extra-source-files: include/EventLogFormat.h
test/queens-ghc-7.0.2.eventlog.reference
test/mandelbrot-mmc-2011-06-14.eventlog
test/mandelbrot-mmc-2011-06-14.eventlog.reference
test/nonmoving-gc.eventlog
test/nonmoving-gc.eventlog.reference
test/nonmoving-gc-census.eventlog
test/nonmoving-gc-census.eventlog.reference
test/parallelTest.eventlog
test/parallelTest.eventlog.reference
test/pre77stop.eventlog
Expand Down
11 changes: 10 additions & 1 deletion include/EventLogFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,21 @@

#define EVENT_USER_BINARY_MSG 181

#define EVENT_CONC_MARK_BEGIN 200
#define EVENT_CONC_MARK_END 201
#define EVENT_CONC_SYNC_BEGIN 202
#define EVENT_CONC_SYNC_END 203
#define EVENT_CONC_SWEEP_BEGIN 204
#define EVENT_CONC_SWEEP_END 205
#define EVENT_CONC_UPD_REM_SET_FLUSH 206
#define EVENT_NONMOVING_HEAP_CENSUS 207

/*
* The highest event code +1 that ghc itself emits. Note that some event
* ranges higher than this are reserved but not currently emitted by ghc.
* This must match the size of the EventDesc[] array in EventLog.c
*/
#define NUM_GHC_EVENT_TAGS 182
#define NUM_GHC_EVENT_TAGS 208


/* DEPRECATED EVENTS: */
Expand Down
16 changes: 16 additions & 0 deletions src/GHC/RTS/EventTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,22 @@ data EventInfo

| UserBinaryMessage { payload :: !B.ByteString
}

| ConcMarkBegin
| ConcMarkEnd { concMarkedObjectCount :: !Word32
}
| ConcSyncBegin
| ConcSyncEnd
| ConcSweepBegin
| ConcSweepEnd
| ConcUpdRemSetFlush { cap :: {-# UNPACK #-}!Int
}
| NonmovingHeapCensus
{ nonmovingCensusBlkSize :: !Word8
, nonmovingCensusActiveSegs :: !Word32
, nonmovingCensusFilledSegs :: !Word32
, nonmovingCensusLiveBlocks :: !Word32
}
deriving Show

{- [Note: Stop status in GHC-7.8.2]
Expand Down
21 changes: 21 additions & 0 deletions src/GHC/RTS/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,27 @@ buildEventInfo spec' =
UserBinaryMessage {..} ->
"binary message " <> TB.fromText (replaceUnprintableWith '.' payload)

ConcMarkBegin ->
"concurrent mark began"
ConcMarkEnd {..} ->
"concurrent mark ended: "
<> "marked " <> TB.decimal concMarkedObjectCount <> " objects"
ConcSyncBegin ->
"post-mark synchronization began"
ConcSyncEnd ->
"post-mark synchronization ended"
ConcSweepBegin ->
"concurrent sweep began"
ConcSweepEnd ->
"concurrent sweep ended"
ConcUpdRemSetFlush {..} ->
"update remembered set flushed by " <> TB.decimal cap
NonmovingHeapCensus {..} ->
"nonmoving heap census " <> TB.decimal (2^nonmovingCensusBlkSize :: Int)
<> ": " <> TB.decimal nonmovingCensusActiveSegs <> " active segments"
<> ", " <> TB.decimal nonmovingCensusFilledSegs <> " filled segments"
<> ", " <> TB.decimal nonmovingCensusLiveBlocks <> " live blocks"

-- | Replace unprintable bytes in the message with the replacement character
replaceUnprintableWith
:: Char -- ^ Replacement character
Expand Down
44 changes: 44 additions & 0 deletions src/GHC/RTS/Events/Binary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,27 @@ standardParsers = [
str <- getText (num - sz_tid)
return ThreadLabel{ thread = tid
, threadlabel = str }
)),

(simpleEvent EVENT_CONC_MARK_BEGIN ConcMarkBegin),
(FixedSizeParser EVENT_CONC_MARK_END 4 (do -- (marked_object_count)
num <- get :: Get Word32
return ConcMarkEnd{ concMarkedObjectCount = num }
)),
(simpleEvent EVENT_CONC_SYNC_BEGIN ConcSyncBegin),
(simpleEvent EVENT_CONC_SYNC_END ConcSyncEnd),
(simpleEvent EVENT_CONC_SWEEP_BEGIN ConcSweepBegin),
(simpleEvent EVENT_CONC_SWEEP_END ConcSweepEnd),
(FixedSizeParser EVENT_CONC_UPD_REM_SET_FLUSH sz_cap (do -- (cap)
cap <- get :: Get CapNo
return ConcUpdRemSetFlush{ cap = fromIntegral cap }
)),
(FixedSizeParser EVENT_NONMOVING_HEAP_CENSUS 13 (do -- (blk_size, active_segs, filled_segs, live_blks)
nonmovingCensusBlkSize <- get :: Get Word8
nonmovingCensusActiveSegs <- get :: Get Word32
nonmovingCensusFilledSegs <- get :: Get Word32
nonmovingCensusLiveBlocks <- get :: Get Word32
return NonmovingHeapCensus{..}
))
]

Expand Down Expand Up @@ -1002,6 +1023,14 @@ eventTypeNum e = case e of
ProfSampleCostCentre {} -> EVENT_PROF_SAMPLE_COST_CENTRE
ProfBegin {} -> EVENT_PROF_BEGIN
UserBinaryMessage {} -> EVENT_USER_BINARY_MSG
ConcMarkBegin {} -> EVENT_CONC_MARK_BEGIN
ConcMarkEnd {} -> EVENT_CONC_MARK_END
ConcSyncBegin {} -> EVENT_CONC_SYNC_BEGIN
ConcSyncEnd {} -> EVENT_CONC_SYNC_END
ConcSweepBegin {} -> EVENT_CONC_SWEEP_BEGIN
ConcSweepEnd {} -> EVENT_CONC_SWEEP_END
ConcUpdRemSetFlush {} -> EVENT_CONC_UPD_REM_SET_FLUSH
NonmovingHeapCensus {} -> EVENT_NONMOVING_HEAP_CENSUS

nEVENT_PERF_NAME, nEVENT_PERF_COUNTER, nEVENT_PERF_TRACEPOINT :: EventTypeNum
nEVENT_PERF_NAME = EVENT_PERF_NAME
Expand Down Expand Up @@ -1427,3 +1456,18 @@ putEventSpec ProfBegin {..} = do
putEventSpec UserBinaryMessage {..} = do
putE (fromIntegral (B.length payload) :: Word16)
putByteString payload

putEventSpec ConcMarkBegin = return ()
putEventSpec ConcMarkEnd {..} = do
putE concMarkedObjectCount
putEventSpec ConcSyncBegin = return ()
putEventSpec ConcSyncEnd = return ()
putEventSpec ConcSweepBegin = return ()
putEventSpec ConcSweepEnd = return ()
putEventSpec ConcUpdRemSetFlush {..} = do
putCap cap
putEventSpec NonmovingHeapCensus {..} = do
putE nonmovingCensusBlkSize
putE nonmovingCensusActiveSegs
putE nonmovingCensusFilledSegs
putE nonmovingCensusLiveBlocks
2 changes: 2 additions & 0 deletions test/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ files = map ("test/"++)
[ "queens-ghc-6.12.1.eventlog"
, "queens-ghc-7.0.2.eventlog"
, "mandelbrot-mmc-2011-06-14.eventlog"
, "nonmoving-gc.eventlog"
, "nonmoving-gc-census.eventlog"
, "parallelTest.eventlog"
, "pre77stop.eventlog", "782stop.eventlog", "783stop.eventlog"
, "sleep.h.eventlog"
Expand Down
Binary file added test/nonmoving-gc-census.eventlog
Binary file not shown.
Loading

0 comments on commit e811ce7

Please sign in to comment.