[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: rts: Enable tracing of nonmoving heap census with -ln

Marge Bot gitlab at gitlab.haskell.org
Sun May 3 19:16:54 UTC 2020



 Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00
rts: Enable tracing of nonmoving heap census with -ln

Previously this was not easily available to the user. Fix this.
Non-moving collection lifecycle events are now reported with -lg.

- - - - -
c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00
users guide: Move eventlog documentation users guide

- - - - -
02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00
users guide: Add documentation for non-moving GC events

- - - - -
b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00
Flatten nested casts in the simple optimizer

Normally, we aren’t supposed to generated any nested casts, since mkCast
takes care to flatten them, but the simple optimizer didn’t use mkCast,
so they could show up after inlining. This isn’t really a problem, since
the simplifier will clean them up immediately anyway, but it can clutter
the -ddump-ds output, and it’s an extremely easy fix.

closes #18112

- - - - -
1e1e32a6 by Simon Peyton Jones at 2020-05-03T15:16:40-04:00
Don't return a panic in tcNestedSplice

In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a
typechecked expression of "panic". That is usually OK, because
the result is discarded.  But it happens that tcApp now looks at
the typechecked expression, trivially, to ask if it is tagToEnum.
So being bottom is bad.

Moreover a debug-trace might print it out.

So better to return a civilised expression, even though it is
usually discarded.

- - - - -
1c49d150 by Baldur Blöndal at 2020-05-03T15:16:44-04:00
Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130".

- - - - -


20 changed files:

- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Parser.y
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Splice.hs
- docs/users_guide/conf.py
- docs/users_guide/eventlog-formats.rst
- docs/users_guide/runtime_control.rst
- includes/rts/EventLogFormat.h
- rts/RtsFlags.c
- rts/sm/NonMoving.c
- + testsuite/tests/deSugar/should_compile/T18112.hs
- testsuite/tests/deSugar/should_compile/all.T
- testsuite/tests/dependent/should_compile/dynamic-paper.stderr
- + testsuite/tests/parser/should_compile/T18130.hs
- testsuite/tests/parser/should_compile/all.T
- + testsuite/tests/parser/should_fail/T18130Fail.hs
- + testsuite/tests/parser/should_fail/T18130Fail.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/th/T18121.hs
- testsuite/tests/th/all.T


Changes:

=====================================
compiler/GHC/Core/SimpleOpt.hs
=====================================
@@ -221,10 +221,13 @@ simple_opt_expr env expr
     go (Coercion co)    = Coercion (optCoercion (soe_dflags env) (getTCvSubst subst) co)
     go (Lit lit)        = Lit lit
     go (Tick tickish e) = mkTick (substTickish subst tickish) (go e)
-    go (Cast e co)      | isReflCo co' = go e
-                        | otherwise    = Cast (go e) co'
-                        where
-                          co' = optCoercion (soe_dflags env) (getTCvSubst subst) co
+    go (Cast e co)      = case go e of
+                            -- flatten nested casts before calling the coercion optimizer;
+                            -- see #18112 (note that mkCast handles dropping Refl coercions)
+                            Cast e' co' -> mkCast e' (opt_co (mkTransCo co' co))
+                            e'          -> mkCast e' (opt_co co)
+                          where
+                            opt_co = optCoercion (soe_dflags env) (getTCvSubst subst)
 
     go (Let bind body)  = case simple_opt_bind env bind NotTopLevel of
                              (env', Nothing)   -> simple_opt_expr env' body


=====================================
compiler/GHC/Parser.y
=====================================
@@ -1209,8 +1209,8 @@ deriv_strategy_no_via :: { LDerivStrategy GhcPs }
                                        [mj AnnNewtype $1] }
 
 deriv_strategy_via :: { LDerivStrategy GhcPs }
-  : 'via' type              {% ams (sLL $1 $> (ViaStrategy (mkLHsSigType $2)))
-                                            [mj AnnVia $1] }
+  : 'via' ktype             {% ams (sLL $1 $> (ViaStrategy (mkLHsSigType $2)))
+                                       [mj AnnVia $1] }
 
 deriv_standalone_strategy :: { Maybe (LDerivStrategy GhcPs) }
   : 'stock'                     {% ajs (sL1 $1 StockStrategy)


=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -981,12 +981,9 @@ tcExpr (HsSpliceE _ (HsSpliced _ mod_finalizers (HsSplicedExpr expr)))
        res_ty
   = do addModFinalizersWithLclEnv mod_finalizers
        tcExpr expr res_ty
-tcExpr (HsSpliceE _ splice)          res_ty
-  = tcSpliceExpr splice res_ty
-tcExpr e@(HsBracket _ brack)         res_ty
-  = tcTypedBracket e brack res_ty
-tcExpr e@(HsRnBracketOut _ brack ps) res_ty
-  = tcUntypedBracket e brack ps res_ty
+tcExpr (HsSpliceE _ splice)          res_ty = tcSpliceExpr splice res_ty
+tcExpr e@(HsBracket _ brack)         res_ty = tcTypedBracket e brack res_ty
+tcExpr e@(HsRnBracketOut _ brack ps) res_ty = tcUntypedBracket e brack ps res_ty
 
 {-
 ************************************************************************
@@ -1219,7 +1216,11 @@ tcApp expr res_ty
   = do { (fun, args, app_res_ty) <- tcInferApp expr
        ; if isTagToEnum fun
          then tcTagToEnum expr fun args app_res_ty res_ty
-         else -- The wildly common case
+              -- Done here because we have res_ty,
+              -- whereas tcInferApp does not
+         else
+
+    -- The wildly common case
     do { let expr' = applyHsArgs fun args
        ; addFunResCtxt True fun app_res_ty res_ty $
          tcWrapResult expr expr' app_res_ty res_ty } }
@@ -1232,10 +1233,10 @@ tcInferApp :: HsExpr GhcRn
 -- Also used by Module.tcRnExpr to implement GHCi :type
 tcInferApp expr
   | -- Gruesome special case for ambiguous record selectors
-    HsRecFld _ fld_lbl   <- fun
-  , Ambiguous _ lbl              <- fld_lbl  -- Still ambiguous
+    HsRecFld _ fld_lbl        <- fun
+  , Ambiguous _ lbl           <- fld_lbl  -- Still ambiguous
   , HsEValArg _ (L _ arg) : _ <- filterOut isArgPar args -- A value arg is first
-  , Just sig_ty <- obviousSig arg  -- A type sig on the arg disambiguates
+  , Just sig_ty               <- obviousSig arg  -- A type sig on the arg disambiguates
   = do { sig_tc_ty <- tcHsSigWcType ExprSigCtxt sig_ty
        ; sel_name  <- disambiguateSelector lbl sig_tc_ty
        ; (tc_fun, fun_ty) <- tcInferRecSelId (Unambiguous sel_name lbl)
@@ -1259,11 +1260,7 @@ tcInferApp_finish
     -> TcM (HsExpr GhcTc, [LHsExprArgOut], TcSigmaType)
 
 tcInferApp_finish rn_fun tc_fun fun_sigma rn_args
-  = do { traceTc "tcInferApp_finish" $
-         vcat [ ppr rn_fun <+> dcolon <+> ppr fun_sigma, ppr rn_args ]
-
-       ; (tc_args, actual_res_ty) <- tcArgs rn_fun fun_sigma rn_args
-
+  = do { (tc_args, actual_res_ty) <- tcArgs rn_fun fun_sigma rn_args
        ; return (tc_fun, tc_args, actual_res_ty) }
 
 mk_op_msg :: LHsExpr GhcRn -> SDoc


=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -625,7 +625,13 @@ tcNestedSplice pop_stage (TcPending ps_var lie_var q@(QuoteWrapper _ m_var)) spl
        ; writeMutVar ps_var (PendingTcSplice splice_name expr'' : ps)
 
        -- The returned expression is ignored; it's in the pending splices
-       ; return (panic "tcSpliceExpr") }
+       -- But we still return a plausible expression
+       --   (a) in case we print it in debug messages, and
+       --   (b) because we test whether it is tagToEnum in Tc.Gen.Expr.tcApp
+       ; return (HsSpliceE noExtField $
+                 HsSpliced noExtField (ThModFinalizers []) $
+                 HsSplicedExpr (unLoc expr'')) }
+
 
 tcNestedSplice _ _ splice_name _ _
   = pprPanic "tcNestedSplice: rename stage found" (ppr splice_name)


=====================================
docs/users_guide/conf.py
=====================================
@@ -283,8 +283,18 @@ def setup(app):
                         objname='runtime system command-line option',
                         parse_node=parse_flag,
                         indextemplate='pair: %s; RTS option',
+                        doc_field_types=[
+                            Field('since', label='Introduced in GHC version', names=['since'])
+                        ])
+
+    app.add_object_type('event-type', 'event-type',
+                        objname='event log event type',
+                        indextemplate='pair: %s; eventlog event type',
                         doc_field_types=[
                             Field('since', label='Introduced in GHC version', names=['since']),
+                            Field('tag', label='Event type ID', names=['tag']),
+                            Field('length', label='Record length', names=['length']),
+                            TypedField('fields', label='Fields', names='field', typenames=('fieldtype', 'type'))
                         ])
 
     app.add_object_type('pragma', 'pragma',


=====================================
docs/users_guide/eventlog-formats.rst
=====================================
@@ -1,3 +1,5 @@
+.. _eventlog-encodings:
+
 Eventlog encodings
 ==================
 
@@ -7,6 +9,481 @@ thread scheduling events, garbage collection statistics, profiling information,
 user-defined tracing events.
 
 This section is intended for implementors of tooling which consume these events.
+GHC ships with a C header file (``EventlogFormat.h``) which provides symbolic
+names for the event type IDs described in this file.
+
+
+Event log format
+----------------
+
+The log format is designed to be extensible: old tools should be
+able to parse (but not necessarily understand all of) new versions
+of the format, and new tools will be able to understand old log
+files.
+
+- The format is endian-independent: all values are represented in
+  big-endian order.
+
+- The format is extensible:
+
+  - The header describes each event type and its length.  Tools
+    that don't recognise a particular event type can skip those events.
+
+  - There is room for extra information in the event type
+    specification, which can be ignored by older tools.
+
+  - Events can have extra information added, but existing fields
+    cannot be changed.  Tools should ignore extra fields at the
+    end of the event record.
+
+The event-log stream begins with a header describing the event types present in
+the file. The header is followed by the event records themselves, each of which
+consist of a 64-bit timestamp
+
+.. code-block:: none
+
+    log : EVENT_HEADER_BEGIN
+          EventType*
+          EVENT_HEADER_END
+          EVENT_DATA_BEGIN
+          Event*
+          EVENT_DATA_END
+
+    EventType :
+          EVENT_ET_BEGIN
+          Word16         -- unique identifier for this event
+          Int16          -- >=0  size of the event in bytes (minus the header)
+                         -- -1   variable size
+          Word32         -- length of the next field in bytes
+          Word8*         -- string describing the event
+          Word32         -- length of the next field in bytes
+          Word8*         -- extra info (for future extensions)
+          EVENT_ET_END
+
+    Event :
+          Word16         -- event_type
+          Word64         -- time (nanosecs)
+          [Word16]       -- length of the rest (for variable-sized events only)
+          ... extra event-specific info ...
+
+There are two classes of event types:
+
+ - *Fixed size*: All event records of a fixed-sized type are of the same
+   length, given in the header event-log header.
+
+ - *Variable size*: Each event record includes a length field.
+
+Runtime system diagnostics
+--------------------------
+
+ * ``ThreadId ~ Word32``
+ * ``CapNo ~ Word16``
+ * ``CapSetId ~ Word32``
+
+Capability sets
+~~~~~~~~~~~~~~~
+
+TODO
+
+Environment information
+~~~~~~~~~~~~~~~~~~~~~~~
+
+These events are typically produced during program startup and describe the
+environment which the program is being run in.
+
+.. event-type:: RTS_IDENTIFIER
+
+   :tag: 29
+   :length: variable
+   :field CapSetId: Capability set
+   :field String: Runtime system name and version.
+
+   Describes the name and version of the runtime system responsible for the
+   indicated capability set.
+
+.. event-type:: PROGRAM_ARGS
+
+   :tag: 30
+   :length: variable
+   :field CapSetId: Capability set
+   :field [String]: The command-line arguments passed to the program
+
+   Describes the command-line used to start the program.
+
+.. event-type:: PROGRAM_ENV
+
+   :tag: 31
+   :length: variable
+   :field CapSetId: Capability set
+   :field [String]: The environment variable name/value pairs. (TODO: encoding?)
+
+   Describes the environment variables present in the program's environment.
+
+Thread and scheduling events
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. event-type:: CREATE_THREAD
+
+   :tag: 0
+   :length: fixed
+   :field ThreadId: thread id
+
+   Marks the creation of a Haskell thread.
+
+
+.. event-type:: RUN_THREAD
+
+   :tag: 1
+   :length: fixed
+   :field ThreadId: thread id
+
+   The indicated thread has started running.
+
+
+.. event-type:: STOP_THREAD
+
+   :tag: 2
+   :length: fixed
+   :field ThreadId: thread id
+   :field Word16: status
+
+      * 1: HeapOverflow
+      * 2: StackOverflow
+      * 3: ThreadYielding
+      * 4: ThreadBlocked
+      * 5: ThreadFinished
+      * 6: ForeignCall
+      * 7: BlockedOnMVar
+      * 8: BlockedOnBlackHole
+      * 9: BlockedOnRead
+      * 10: BlockedOnWrite
+      * 11: BlockedOnDelay
+      * 12: BlockedOnSTM
+      * 13: BlockedOnDoProc
+      * 16: BlockedOnMsgThrowTo
+
+   :field ThreadId: thread id of thread being blocked on (only for some status
+                    values)
+
+   The indicated thread has stopped running for the reason given by ``status``.
+
+
+.. event-type:: THREAD_RUNNABLE
+
+   :tag: 3
+   :length: fixed
+   :field ThreadId: thread id
+
+   The indicated thread is has been marked as ready to run.
+
+
+.. event-type:: MIGRATE_THREAD
+
+   :tag: 4
+   :length: fixed
+   :field ThreadId: thread id
+   :field CapNo: capability
+
+   The indicated thread has been migrated to a new capability.
+
+
+.. event-type:: THREAD_WAKEUP
+
+   :tag: 8
+   :length: fixed
+   :field ThreadId: thread id
+   :field CapNo: other capability
+
+   The indicated thread has been been woken up on another capability.
+
+.. event-type:: THREAD_LABEL
+
+   :tag: 44
+   :length: fixed
+   :field ThreadId: thread id
+   :field String: label
+
+   The indicated thread has been given a label (e.g. with
+   :base-ref:`Control.Concurrent.setThreadLabel`).
+
+
+Garbage collector events
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. event-type:: GC_START
+
+   :tag: 9
+   :length: fixed
+
+   A garbage collection pass has been started.
+
+.. event-type:: GC_END
+
+   :tag: 10
+   :length: fixed
+
+   A garbage collection pass has been finished.
+
+.. event-type:: REQUEST_SEQ_GC
+
+   :tag: 11
+   :length: fixed
+
+   A sequential garbage collection has been requested by a capability.
+
+.. event-type:: REQUEST_PAR_GC
+
+   :tag: 12
+   :length: fixed
+
+   A parallel garbage collection has been requested by a capability.
+
+.. event-type:: GC_IDLE
+
+   :tag: 20
+   :length: fixed
+
+   An idle-time garbage collection has been started.
+
+.. event-type:: GC_WORK
+
+   :tag: 21
+   :length: fixed
+
+   Marks the start of concurrent scavenging.
+
+.. event-type:: GC_DONE
+
+   :tag: 22
+   :length: fixed
+
+   Marks the end of concurrent scavenging.
+
+.. event-type:: GC_STATS_GHC
+
+   :tag: 53
+   :length: fixed
+   :field CapSetId: heap capability set
+   :field Word16: generation of collection
+   :field Word64: bytes copied
+   :field Word64: bytes of slop found
+   :field Word64: TODO
+   :field Word64: number of parallel garbage collection threads
+   :field Word64: maximum number of bytes copied by any single collector thread
+   :field Word64: total bytes copied by all collector threads
+
+   Report various information about the heap configuration. Typically produced
+   during RTS initialization..
+
+.. event-type:: GC_GLOBAL_SYNC
+
+   :tag: 54
+   :length: fixed
+
+   TODO
+
+Heap events and statistics
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. event-type:: HEAP_ALLOCATED
+
+   :tag: 49
+   :length: fixed
+   :field CapSetId: heap capability set
+   :field Word64: allocated bytes
+
+   A new chunk of heap has been allocated by the indicated capability set.
+
+.. event-type:: HEAP_SIZE
+
+   :tag: 50
+   :length: fixed
+   :field CapSetId: heap capability set
+   :field Word64: heap size in bytes
+
+   Report the heap size.
+
+.. event-type:: HEAP_LIVE
+
+   :tag: 51
+   :length: fixed
+   :field CapSetId: heap capability set
+   :field Word64: heap size in bytes
+
+   Report the live heap size.
+
+.. event-type:: HEAP_INFO_GHC
+
+   :tag: 52
+   :length: fixed
+   :field CapSetId: heap capability set
+   :field Word16: number of garbage collection generations
+   :field Word64: maximum heap size
+   :field Word64: allocation area size
+   :field Word64: MBlock size
+   :field Word64: Block size
+
+   Report various information about the heap configuration. Typically produced
+   during RTS initialization..
+
+Spark events
+~~~~~~~~~~~~
+
+.. event-type:: CREATE_SPARK_THREAD
+
+   :tag: 15
+   :length: fixed
+
+   A thread has been created to perform spark evaluation.
+
+.. event-type:: SPARK_COUNTERS
+
+   :tag: 34
+   :length: fixed
+
+   A periodic reporting of various statistics of spark evaluation.
+
+.. event-type:: SPARK_CREATE
+
+   :tag: 35
+   :length: fixed
+
+   A spark has been added to the spark pool.
+
+.. event-type:: SPARK_DUD
+
+   :tag: 36
+   :length: fixed
+
+   TODO
+
+.. event-type:: SPARK_OVERFLOW
+
+   :tag: 37
+   :length: fixed
+
+   TODO
+
+.. event-type:: SPARK_RUN
+
+   :tag: 38
+   :length: fixed
+
+   Evaluation has started on a spark.
+
+.. event-type:: SPARK_STEAL
+
+   :tag: 39
+   :length: fixed
+   :field Word16: capability from which the spark was stolen
+
+   A spark has been stolen from another capability for evaluation.
+
+.. event-type:: SPARK_FIZZLE
+
+   :tag: 40
+   :length: fixed
+
+   A spark has been GC'd before being evaluated.
+
+.. event-type:: SPARK_GC
+
+   :tag: 41
+   :length: fixed
+
+   An unevaluated spark has been garbage collected.
+
+Capability events
+~~~~~~~~~~~~~~~~~
+
+.. event-type:: CAP_CREATE
+
+   :tag: 45
+   :length: fixed
+   :field CapNo: the capability number
+
+   A capability has been started.
+
+.. event-type:: CAP_DELETE
+
+   :tag: 46
+   :length: fixed
+
+   A capability has been deleted.
+
+.. event-type:: CAP_DISABLE
+
+   :tag: 47
+   :length: fixed
+
+   A capability has been disabled.
+
+.. event-type:: CAP_ENABLE
+
+   :tag: 48
+   :length: fixed
+
+   A capability has been enabled.
+
+Task events
+~~~~~~~~~~~
+
+.. event-type:: TASK_CREATE
+
+   :tag: 55
+   :length: fixed
+   :field TaskId: task id
+   :field CapNo: capability number
+   :field ThreadId: TODO
+
+   Marks the creation of a task.
+
+.. event-type:: TASK_MIGRATE
+
+   :tag: 56
+   :length: fixed
+   :field TaskId: task id
+   :field CapNo: old capability
+   :field CapNo: new capability
+
+   Marks the migration of a task to a new capability.
+
+Tracing events
+~~~~~~~~~~~~~~
+
+.. event-type:: LOG_MSG
+
+   :tag: 16
+   :length: variable
+   :field String: The message
+
+   A log message from the runtime system.
+
+.. event-type:: BLOCK_MARKER
+
+   :tag: 18
+   :length: variable
+   :field Word32: size
+   :field Word64: end time in nanoseconds
+   :field String: marker name
+
+   TODO
+
+.. event-type:: USER_MSG
+
+   :tag: 19
+   :length: variable
+   :field String: message
+
+   A user log message (from, e.g., :base-ref:`Control.Concurrent.traceEvent`).
+
+.. event-type:: USER_MARKER
+
+   :tag: 58
+   :length: variable
+   :field String: marker name
+
+   A user marker (from :base-ref:`Debug.Trace.traceMarker`).
 
 
 .. _heap-profiler-events:
@@ -28,11 +505,13 @@ Beginning of sample stream
 
 A single fixed-width event emitted during program start-up describing the samples that follow.
 
- * ``EVENT_HEAP_PROF_BEGIN``
+.. event-type:: HEAP_PROF_BEGIN
 
-   * ``Word8``: Profile ID
-   * ``Word64``: Sampling period in nanoseconds
-   * ``Word32``: Sample break-down type. One of,
+   :tag: 160
+   :length: variable
+   :field Word8: profile ID
+   :field Word64: sampling period in nanoseconds
+   :field Word32: sample breadown type. One of,
 
       * ``HEAP_PROF_BREAKDOWN_COST_CENTER`` (output from :rts-flag:`-hc`)
       * ``HEAP_PROF_BREAKDOWN_CLOSURE_DESCR`` (output from :rts-flag:`-hd`)
@@ -42,32 +521,34 @@ A single fixed-width event emitted during program start-up describing the sample
       * ``HEAP_PROF_BREAKDOWN_BIOGRAPHY`` (output from :rts-flag:`-hb`)
       * ``HEAP_PROF_BREAKDOWN_CLOSURE_TYPE`` (output from :rts-flag:`-hT`)
 
-   * ``String``: Module filter
-   * ``String``: Closure description filter
-   * ``String``: Type description filter
-   * ``String``: Cost centre filter
-   * ``String``: Cost centre stack filter
-   * ``String``: Retainer filter
-   * ``String``: Biography filter
+   :field String: module filter
+   :field String: closure description filter
+   :field String: type description filter
+   :field String: cost centre filter
+   :field String: cost centre stack filter
+   :field String: retainer filter
+   :field String: biography filter
 
 Cost centre definitions
 ^^^^^^^^^^^^^^^^^^^^^^^
 
 A variable-length packet produced once for each cost centre,
 
- * ``EVENT_HEAP_PROF_COST_CENTRE``
+.. event-type:: HEAP_PROF_COST_CENTRE
 
-   * ``Word32``: cost centre number
-   * ``String``: label
-   * ``String``: module
-   * ``String``: source location
-   * ``Word8``: flags
+   :tag: 161
+   :length: fixed
+   :field Word32: cost centre number
+   :field String: label
+   :field String: module
+   :field String: source location
+   :field Word8: flags:
 
      * bit 0: is the cost-centre a CAF?
 
 
 Sample event types
-~~~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^^^
 
 A sample (consisting of a list of break-down classes, e.g. cost centres, and
 heap residency sizes), is to be encoded in the body of one or more events.
@@ -75,9 +556,12 @@ heap residency sizes), is to be encoded in the body of one or more events.
 We normally mark the beginning of a new sample with an ``EVENT_HEAP_PROF_SAMPLE_BEGIN``
 event,
 
- * ``EVENT_HEAP_PROF_SAMPLE_BEGIN``
+.. event-type:: HEAP_PROF_SAMPLE_BEGIN
+
+   :length: fixed
+   :field Word64: sample number
 
-   * ``Word64``: sample number
+   Marks the beginning of a heap profile sample.
 
 Biographical profiling samples start with the ``EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN``
 event. These events also include a timestamp which indicates when the sample
@@ -85,11 +569,12 @@ was taken. This is because all these samples will appear at the end of
 the eventlog due to how the biographical profiling mode works. You can
 use the timestamp to reorder the samples relative to the other events.
 
- * ``EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN``
-
-   * ``Word64``: sample number
-   * ``Word64``: eventlog timestamp in ns
+.. event-type:: HEAP_BIO_PROF_SAMPLE_BEGIN
 
+   :tag: 166
+   :length: fixed
+   :field Word64: sample number
+   :field Word64: eventlog timestamp in ns
 
 A heap residency census will follow. Since events may only be up to 2^16^ bytes
 in length a single sample may need to be split among multiple
@@ -101,23 +586,29 @@ emitted. This is useful to properly delimit the sampling period and to record
 the total time spent profiling.
 
 
- * ``EVENT_HEAP_PROF_SAMPLE_END``
-   * ``Word64``: sample number
+.. event-type:: HEAP_PROF_SAMPLE_END
 
+   :tag: 165
+   :length: fixed
+   :field Word64: sample number
+
+   Marks the end of a heap profile sample.
 
 Cost-centre break-down
 ^^^^^^^^^^^^^^^^^^^^^^
 
 A variable-length packet encoding a heap profile sample broken down by,
- * cost-centre (``-hc``)
+ * cost-centre (:rts-flag:`-hc`)
 
 
- * ``EVENT_HEAP_PROF_SAMPLE_COST_CENTRE``
+.. event-type:: HEAP_PROF_SAMPLE_COST_CENTRE
 
-   * ``Word8``: Profile ID
-   * ``Word64``: heap residency in bytes
-   * ``Word8``: stack depth
-   * ``Word32[]``: cost centre stack starting with inner-most (cost centre numbers)
+   :tag: 163
+   :length: variable
+   :field Word8: profile ID
+   :field Word64: heap residency in bytes
+   :field Word8: stack depth
+   :field Word32[]: cost centre stack starting with inner-most (cost centre numbers)
 
 
 String break-down
@@ -125,42 +616,142 @@ String break-down
 
 A variable-length event encoding a heap sample broken down by,
 
- * type description (``-hy``)
- * closure description (``-hd``)
- * module (``-hm``)
+ * type description (:rts-flag:`-hy`)
+ * closure description (:rts-flag:`-hd`)
+ * module (:rts-flag:`-hm`)
 
- * ``EVENT_HEAP_PROF_SAMPLE_STRING``
+.. event-type:: HEAP_PROF_SAMPLE_STRING
 
-   * ``Word8``: Profile ID
-   * ``Word64``: heap residency in bytes
-   * ``String``: type or closure description, or module name
+   :tag: 164
+   :length: variable
+   :field Word8: profile ID
+   :field Word64: heap residency in bytes
+   :field String: type or closure description, or module name
 
 .. _time-profiler-events:
 
 Time profiler event log output
 ------------------------------
 
-The time profiling mode enabled by ``-p`` also emits sample events to the eventlog.
-At the start of profiling the tick interval is emitted to the eventlog and then
-on each tick the current cost centre stack is emitted. Together these enable
-a user to construct an approximate track of the executation of their program.
+The time profiling mode enabled by :rts-flag:`-p` also emits
+sample events to the eventlog.  At the start of profiling the
+tick interval is emitted to the eventlog and then on each tick
+the current cost centre stack is emitted. Together these
+enable a user to construct an approximate track of the
+executation of their program.
 
 Profile begin event
 ~~~~~~~~~~~~~~~~~~~
 
- * ``EVENT_PROF_BEGIN``
+.. event-type:: PROF_BEGIN
 
-   * ``Word64``: Tick interval, in nanoseconds
+   :tag: 168
+   :length: fixed
+   :field Word64: tick interval, in nanoseconds
 
+   Marks the beginning of a time profile.
 
-Tick sample event
-~~~~~~~~~~~~~~~~~
+Profile sample event
+~~~~~~~~~~~~~~~~~~~~
 
 A variable-length packet encoding a profile sample.
 
-  * ``EVENT_PROF_SAMPLE_COST_CENTRE``
+.. event-type:: PROF_SAMPLE_COST_CENTRE
+
+   :tag: 167
+   :length: variable
+   :field Word32: capability
+   :field Word64: current profiling tick
+   :field Word8: stack depth
+   :field Word32[]: cost centre stack starting with inner-most (cost centre numbers)
+
+Biographical profile sample event
+---------------------------------
+
+A variable-length packet encoding a profile sample.
+
+.. event-type:: BIO_PROF_SAMPLE_BEGIN
+
+   :tag: 166
+
+   TODO
+
+.. _nonmoving-gc-events:
+
+Non-moving GC event output
+--------------------------
+
+These events mark various stages of the
+:rts-flag:`non-moving collection <--nonmoving-gc>` lifecycle. These are enabled
+with the ``+RTS -lg`` event-set.
+
+.. event-type:: CONC_MARK_BEGIN
+
+   :tag: 200
+   :length: fixed
+
+   Marks the beginning of marking by the concurrent collector.
+
+.. event-type:: CONC_MARK_END
+
+   :tag: 201
+   :length: fixed
+
+   Marks the end of marking by the concurrent collector.
+
+.. event-type:: CONC_SYNC_BEGIN
+
+   :tag: 202
+   :length: fixed
+
+   Marks the beginning of the concurrent garbage collector's
+   post-mark synchronization phase.
+
+.. event-type:: CONC_SYNC_END
+
+   :tag: 203
+   :length: fixed
+
+   Marks the end of the concurrent garbage collector's
+   post-mark synchronization phase.
+
+.. event-type:: CONC_SWEEP_BEGIN
+
+   :tag: 204
+   :length: fixed
+
+   Marks the beginning of the concurrent garbage collector's
+   sweep phase.
+
+.. event-type:: CONC_SWEEP_END
+
+   :tag: 205
+   :length: fixed
+
+   Marks the end of the concurrent garbage collector's
+   sweep phase.
+
+.. event-type:: CONC_UPD_REM_SET_FLUSH
+
+   :tag: 206
+   :length: fixed
+
+   Marks a capability flushing its local update remembered set
+   accumulator.
+
+Non-moving heap census
+~~~~~~~~~~~~~~~~~~~~~~
+
+The non-moving heap census events (enabled with the ``+RTS -ln`` event-set) are
+intended to provide insight into fragmentation of the non-moving heap.
+
+.. event-type:: NONMOVING_HEAP_CENSUS
+
+   :tag: 207
+   :length: fixed
+   :field Word8: base-2 logarithm of *blk_sz*.
+   :field Word32: number of active segments.
+   :field Word32: number of filled segments.
+   :field Word32: number of live blocks.
 
-    * ``Word32``: Capability
-    * ``Word64``: Current profiling tick
-    * ``Word8``: stack depth
-    * ``Word32[]``: cost centre stack starting with inner-most (cost centre numbers)
+   Describes the occupancy of the *blk_sz* sub-heap.


=====================================
docs/users_guide/runtime_control.rst
=====================================
@@ -1161,6 +1161,10 @@ When the program is linked with the :ghc-flag:`-eventlog` option
 
     - ``g`` — GC events, including GC start/stop. Enabled by default.
 
+    - ``n`` — non-moving garbage collector (see :rts-flag:`--nonmoving-gc`)
+      events including start and end of the concurrent mark and census
+      information to characterise heap fragmentation. Disabled by default.
+
     - ``p`` — parallel sparks (sampled). Enabled by default.
 
     - ``f`` — parallel sparks (fully accurate). Disabled by default.
@@ -1186,9 +1190,8 @@ When the program is linked with the :ghc-flag:`-eventlog` option
     accurate mode every spark event is logged individually. The latter
     has a higher runtime overhead and is not enabled by default.
 
-    The format of the log file is described by the header
-    ``EventLogFormat.h`` that comes with GHC, and it can be parsed in
-    Haskell using the
+    The format of the log file is described in this users guide in
+    :ref:`eventlog-encodings` It can be parsed in Haskell using the
     `ghc-events <http://hackage.haskell.org/package/ghc-events>`__
     library. To dump the contents of a ``.eventlog`` file as text, use
     the tool ``ghc-events show`` that comes with the


=====================================
includes/rts/EventLogFormat.h
=====================================
@@ -9,65 +9,25 @@
  * of the format, and new tools will be able to understand old log
  * files.
  *
- * Each event has a specific format.  If you add new events, give them
- * new numbers: we never re-use old event numbers.
- *
- * - The format is endian-independent: all values are represented in
- *    bigendian order.
- *
- * - The format is extensible:
- *
- *    - The header describes each event type and its length.  Tools
- *      that don't recognise a particular event type can skip those events.
- *
- *    - There is room for extra information in the event type
- *      specification, which can be ignored by older tools.
- *
- *    - Events can have extra information added, but existing fields
- *      cannot be changed.  Tools should ignore extra fields at the
- *      end of the event record.
- *
- *    - Old event type ids are never re-used; just take a new identifier.
- *
- *
- * The format
- * ----------
- *
- * log : EVENT_HEADER_BEGIN
- *       EventType*
- *       EVENT_HEADER_END
- *       EVENT_DATA_BEGIN
- *       Event*
- *       EVENT_DATA_END
- *
- * EventType :
- *       EVENT_ET_BEGIN
- *       Word16         -- unique identifier for this event
- *       Int16          -- >=0  size of the event in bytes (minus the header)
- *                      -- -1   variable size
- *       Word32         -- length of the next field in bytes
- *       Word8*         -- string describing the event
- *       Word32         -- length of the next field in bytes
- *       Word8*         -- extra info (for future extensions)
- *       EVENT_ET_END
- *
- * Event :
- *       Word16         -- event_type
- *       Word64         -- time (nanosecs)
- *       [Word16]       -- length of the rest (for variable-sized events only)
- *       ... extra event-specific info ...
- *
+ * The canonical documentation for the event log format and record layouts is
+ * the "Eventlog encodings" section of the GHC User's Guide.
  *
  * To add a new event
  * ------------------
  *
  *  - In this file:
- *    - give it a new number, add a new #define EVENT_XXX below
+ *    - give it a new number, add a new #define EVENT_XXX
+ *      below. Do not reuse event ids from deprecated event types.
+ *
  *  - In EventLog.c
  *    - add it to the EventDesc array
  *    - emit the event type in initEventLogging()
  *    - emit the new event in postEvent_()
  *    - generate the event itself by calling postEvent() somewhere
+ *
+ *  - Describe the meaning and encoding of the event in the users guide
+ *    (docs/user_guide/eventlog-formats.rst)
+ *
  *  - In the Haskell code to parse the event log file:
  *    - add types and code to read the new event
  *


=====================================
rts/RtsFlags.c
=====================================
@@ -382,6 +382,7 @@ usage_text[] = {
 "             where [flags] can contain:",
 "                s    scheduler events",
 "                g    GC and heap events",
+"                n    non-moving GC heap census events",
 "                p    par spark events (sampled)",
 "                f    par spark events (full detail)",
 "                u    user events (emitted from Haskell code)",


=====================================
rts/sm/NonMoving.c
=====================================
@@ -1125,6 +1125,10 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO *
     if (RtsFlags.DebugFlags.nonmoving_gc)
         nonmovingPrintAllocatorCensus();
 #endif
+#if defined(TRACING)
+    if (RtsFlags.TraceFlags.nonmoving_gc)
+        nonmovingTraceAllocatorCensus();
+#endif
 
     // TODO: Remainder of things done by GarbageCollect (update stats)
 


=====================================
testsuite/tests/deSugar/should_compile/T18112.hs
=====================================
@@ -0,0 +1,14 @@
+{-# LANGUAGE TypeFamilies #-}
+module T18112 where
+
+type family F a where
+  F Int = String
+
+-- This test is really testing the simple optimizer. We expect the
+-- optimized desugared output to contain no casts, since the simple
+-- optimizer should fuse the two casts together after inlining y.
+
+blah :: Bool -> String
+blah x = let y :: F Int
+             y = show x
+         in y


=====================================
testsuite/tests/deSugar/should_compile/all.T
=====================================
@@ -109,3 +109,4 @@ test('T14773b', normal, compile, ['-Wincomplete-patterns'])
 test('T14815', [], makefile_test, ['T14815'])
 test('T13208', [], makefile_test, ['T13208'])
 test('T16615', normal, compile, ['-ddump-ds -dsuppress-uniques'])
+test('T18112', [grep_errmsg('cast')], compile, ['-ddump-ds'])


=====================================
testsuite/tests/dependent/should_compile/dynamic-paper.stderr
=====================================
@@ -12,4 +12,4 @@ Simplifier ticks exhausted
   simplifier non-termination has been judged acceptable.
    
   To see detailed counts use -ddump-simpl-stats
-  Total ticks: 140084
+  Total ticks: 138082


=====================================
testsuite/tests/parser/should_compile/T18130.hs
=====================================
@@ -0,0 +1,20 @@
+{-# Language DerivingVia #-}
+{-# Language KindSignatures #-}
+
+module T18130 where
+
+import Data.Functor.Classes
+import Data.Kind
+
+newtype Par a b = Par (a, b)
+  deriving Eq
+  via (a, b)
+   :: Type
+
+  deriving Eq1
+  via (,) a
+   :: Type -> Type
+
+  deriving Eq2
+  via (,)
+   :: Type -> Type -> Type


=====================================
testsuite/tests/parser/should_compile/all.T
=====================================
@@ -166,3 +166,4 @@ test('proposal-229f',
      multimod_compile_and_run, ['proposal-229f.hs', ''])
 
 test('T15730a', normal, compile_and_run, [''])
+test('T18130', normal, compile, [''])


=====================================
testsuite/tests/parser/should_fail/T18130Fail.hs
=====================================
@@ -0,0 +1,20 @@
+{-# Language DerivingVia #-}
+{-# Language KindSignatures #-}
+
+module T18130Fail where
+
+import Data.Functor.Classes
+import Data.Kind
+
+newtype Par a b = Par (a, b)
+  deriving Eq
+  via (a, b)
+   :: Type -> Type
+
+  deriving Eq1
+  via (,) a
+   :: Type -> Type
+
+  deriving Eq2
+  via (,)
+   :: Type -> Type -> Type


=====================================
testsuite/tests/parser/should_fail/T18130Fail.stderr
=====================================
@@ -0,0 +1,4 @@
+
+T18130Fail.hs:11:7: error:
+    • Expected kind ‘* -> *’, but ‘(a, b)’ has kind ‘*’
+    • In the newtype declaration for ‘Par’


=====================================
testsuite/tests/parser/should_fail/all.T
=====================================
@@ -166,3 +166,4 @@ test('T17162', normal, compile_fail, [''])
 test('proposal-229c', normal, compile_fail, [''])
 test('T15730', normal, compile_fail, [''])
 test('T15730b', normal, compile_fail, [''])
+test('T18130Fail', normal, compile_fail, ['']) 


=====================================
testsuite/tests/th/T18121.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Bug where
+
+import Language.Haskell.TH
+
+sapply :: Q (TExp (a -> b)) -> Q (TExp a) -> Q (TExp b)
+sapply cf cx = [|| $$cf $$cx ||]


=====================================
testsuite/tests/th/all.T
=====================================
@@ -506,3 +506,4 @@ test('T18097', normal, compile, [''])
 test('TH_PprStar', normal, compile, ['-v0 -dsuppress-uniques'])
 test('TH_StringLift', normal, compile, [''])
 test('TH_BytesShowEqOrd', normal, compile_and_run, [''])
+test('T18121', normal, compile, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a9b306d88eb6ea86a7cb7fbcf31f70e8c75b5a54...1c49d150404bef958110dd7167cb6131f550c88a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a9b306d88eb6ea86a7cb7fbcf31f70e8c75b5a54...1c49d150404bef958110dd7167cb6131f550c88a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200503/68194478/attachment-0001.html>


More information about the ghc-commits mailing list