Skip to content

Commit e811ce7

Browse files
authored
Merge pull request #60 from bgamari/nonmoving-gc
Support for non-moving GC events
2 parents fc02061 + 149b9ca commit e811ce7

10 files changed

+532
-1
lines changed

ghc-events.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ extra-source-files: include/EventLogFormat.h
3636
test/queens-ghc-7.0.2.eventlog.reference
3737
test/mandelbrot-mmc-2011-06-14.eventlog
3838
test/mandelbrot-mmc-2011-06-14.eventlog.reference
39+
test/nonmoving-gc.eventlog
40+
test/nonmoving-gc.eventlog.reference
41+
test/nonmoving-gc-census.eventlog
42+
test/nonmoving-gc-census.eventlog.reference
3943
test/parallelTest.eventlog
4044
test/parallelTest.eventlog.reference
4145
test/pre77stop.eventlog

include/EventLogFormat.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,21 @@
202202

203203
#define EVENT_USER_BINARY_MSG 181
204204

205+
#define EVENT_CONC_MARK_BEGIN 200
206+
#define EVENT_CONC_MARK_END 201
207+
#define EVENT_CONC_SYNC_BEGIN 202
208+
#define EVENT_CONC_SYNC_END 203
209+
#define EVENT_CONC_SWEEP_BEGIN 204
210+
#define EVENT_CONC_SWEEP_END 205
211+
#define EVENT_CONC_UPD_REM_SET_FLUSH 206
212+
#define EVENT_NONMOVING_HEAP_CENSUS 207
213+
205214
/*
206215
* The highest event code +1 that ghc itself emits. Note that some event
207216
* ranges higher than this are reserved but not currently emitted by ghc.
208217
* This must match the size of the EventDesc[] array in EventLog.c
209218
*/
210-
#define NUM_GHC_EVENT_TAGS 182
219+
#define NUM_GHC_EVENT_TAGS 208
211220

212221

213222
/* DEPRECATED EVENTS: */

src/GHC/RTS/EventTypes.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,22 @@ data EventInfo
431431

432432
| UserBinaryMessage { payload :: !B.ByteString
433433
}
434+
435+
| ConcMarkBegin
436+
| ConcMarkEnd { concMarkedObjectCount :: !Word32
437+
}
438+
| ConcSyncBegin
439+
| ConcSyncEnd
440+
| ConcSweepBegin
441+
| ConcSweepEnd
442+
| ConcUpdRemSetFlush { cap :: {-# UNPACK #-}!Int
443+
}
444+
| NonmovingHeapCensus
445+
{ nonmovingCensusBlkSize :: !Word8
446+
, nonmovingCensusActiveSegs :: !Word32
447+
, nonmovingCensusFilledSegs :: !Word32
448+
, nonmovingCensusLiveBlocks :: !Word32
449+
}
434450
deriving Show
435451

436452
{- [Note: Stop status in GHC-7.8.2]

src/GHC/RTS/Events.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,27 @@ buildEventInfo spec' =
492492
UserBinaryMessage {..} ->
493493
"binary message " <> TB.fromText (replaceUnprintableWith '.' payload)
494494

495+
ConcMarkBegin ->
496+
"concurrent mark began"
497+
ConcMarkEnd {..} ->
498+
"concurrent mark ended: "
499+
<> "marked " <> TB.decimal concMarkedObjectCount <> " objects"
500+
ConcSyncBegin ->
501+
"post-mark synchronization began"
502+
ConcSyncEnd ->
503+
"post-mark synchronization ended"
504+
ConcSweepBegin ->
505+
"concurrent sweep began"
506+
ConcSweepEnd ->
507+
"concurrent sweep ended"
508+
ConcUpdRemSetFlush {..} ->
509+
"update remembered set flushed by " <> TB.decimal cap
510+
NonmovingHeapCensus {..} ->
511+
"nonmoving heap census " <> TB.decimal (2^nonmovingCensusBlkSize :: Int)
512+
<> ": " <> TB.decimal nonmovingCensusActiveSegs <> " active segments"
513+
<> ", " <> TB.decimal nonmovingCensusFilledSegs <> " filled segments"
514+
<> ", " <> TB.decimal nonmovingCensusLiveBlocks <> " live blocks"
515+
495516
-- | Replace unprintable bytes in the message with the replacement character
496517
replaceUnprintableWith
497518
:: Char -- ^ Replacement character

src/GHC/RTS/Events/Binary.hs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,27 @@ standardParsers = [
317317
str <- getText (num - sz_tid)
318318
return ThreadLabel{ thread = tid
319319
, threadlabel = str }
320+
)),
321+
322+
(simpleEvent EVENT_CONC_MARK_BEGIN ConcMarkBegin),
323+
(FixedSizeParser EVENT_CONC_MARK_END 4 (do -- (marked_object_count)
324+
num <- get :: Get Word32
325+
return ConcMarkEnd{ concMarkedObjectCount = num }
326+
)),
327+
(simpleEvent EVENT_CONC_SYNC_BEGIN ConcSyncBegin),
328+
(simpleEvent EVENT_CONC_SYNC_END ConcSyncEnd),
329+
(simpleEvent EVENT_CONC_SWEEP_BEGIN ConcSweepBegin),
330+
(simpleEvent EVENT_CONC_SWEEP_END ConcSweepEnd),
331+
(FixedSizeParser EVENT_CONC_UPD_REM_SET_FLUSH sz_cap (do -- (cap)
332+
cap <- get :: Get CapNo
333+
return ConcUpdRemSetFlush{ cap = fromIntegral cap }
334+
)),
335+
(FixedSizeParser EVENT_NONMOVING_HEAP_CENSUS 13 (do -- (blk_size, active_segs, filled_segs, live_blks)
336+
nonmovingCensusBlkSize <- get :: Get Word8
337+
nonmovingCensusActiveSegs <- get :: Get Word32
338+
nonmovingCensusFilledSegs <- get :: Get Word32
339+
nonmovingCensusLiveBlocks <- get :: Get Word32
340+
return NonmovingHeapCensus{..}
320341
))
321342
]
322343

@@ -1002,6 +1023,14 @@ eventTypeNum e = case e of
10021023
ProfSampleCostCentre {} -> EVENT_PROF_SAMPLE_COST_CENTRE
10031024
ProfBegin {} -> EVENT_PROF_BEGIN
10041025
UserBinaryMessage {} -> EVENT_USER_BINARY_MSG
1026+
ConcMarkBegin {} -> EVENT_CONC_MARK_BEGIN
1027+
ConcMarkEnd {} -> EVENT_CONC_MARK_END
1028+
ConcSyncBegin {} -> EVENT_CONC_SYNC_BEGIN
1029+
ConcSyncEnd {} -> EVENT_CONC_SYNC_END
1030+
ConcSweepBegin {} -> EVENT_CONC_SWEEP_BEGIN
1031+
ConcSweepEnd {} -> EVENT_CONC_SWEEP_END
1032+
ConcUpdRemSetFlush {} -> EVENT_CONC_UPD_REM_SET_FLUSH
1033+
NonmovingHeapCensus {} -> EVENT_NONMOVING_HEAP_CENSUS
10051034

10061035
nEVENT_PERF_NAME, nEVENT_PERF_COUNTER, nEVENT_PERF_TRACEPOINT :: EventTypeNum
10071036
nEVENT_PERF_NAME = EVENT_PERF_NAME
@@ -1427,3 +1456,18 @@ putEventSpec ProfBegin {..} = do
14271456
putEventSpec UserBinaryMessage {..} = do
14281457
putE (fromIntegral (B.length payload) :: Word16)
14291458
putByteString payload
1459+
1460+
putEventSpec ConcMarkBegin = return ()
1461+
putEventSpec ConcMarkEnd {..} = do
1462+
putE concMarkedObjectCount
1463+
putEventSpec ConcSyncBegin = return ()
1464+
putEventSpec ConcSyncEnd = return ()
1465+
putEventSpec ConcSweepBegin = return ()
1466+
putEventSpec ConcSweepEnd = return ()
1467+
putEventSpec ConcUpdRemSetFlush {..} = do
1468+
putCap cap
1469+
putEventSpec NonmovingHeapCensus {..} = do
1470+
putE nonmovingCensusBlkSize
1471+
putE nonmovingCensusActiveSegs
1472+
putE nonmovingCensusFilledSegs
1473+
putE nonmovingCensusLiveBlocks

test/Utils.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ files = map ("test/"++)
55
[ "queens-ghc-6.12.1.eventlog"
66
, "queens-ghc-7.0.2.eventlog"
77
, "mandelbrot-mmc-2011-06-14.eventlog"
8+
, "nonmoving-gc.eventlog"
9+
, "nonmoving-gc-census.eventlog"
810
, "parallelTest.eventlog"
911
, "pre77stop.eventlog", "782stop.eventlog", "783stop.eventlog"
1012
, "sleep.h.eventlog"

test/nonmoving-gc-census.eventlog

7.91 KB
Binary file not shown.

0 commit comments

Comments
 (0)