Skip to content
Snippets Groups Projects
  1. Nov 22, 2022
    • Duncan Coutts's avatar
      Reveiew feedback: improve one of the TODO comments · 7181b074
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      The one about the nonsense (const False) test on WinIO for there being any IO
      or timers pending, leading to unnecessary complication later in the
      scheduler.
      7181b074
    • Duncan Coutts's avatar
      Pass the Capability *cap explicitly to appendToIOBlockedQueue · 667fe5a4
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler
      though not strictly necessary given that these primops are currently
      only used in the non-threaded RTS.
      667fe5a4
    • Duncan Coutts's avatar
      Pass the Capability *cap explicitly to awaitEvent · 054dcc9d
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      It is currently only used in the non-threaded RTS so it works to use
      MainCapability, but it's a bit nicer to pass the cap anyway. It's
      certainly shorter.
      054dcc9d
    • Duncan Coutts's avatar
      Move the awaitEvent declaration into IOManager.h · 9943baf9
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      And add or adjust comments at the use sites of awaitEvent.
      9943baf9
    • Duncan Coutts's avatar
      Expand emptyThreadQueues inline for clarity · 32946220
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      It was not really adding anything. The name no longer meant anything
      since those I/O and timeout queues do not belong to the scheuler.
      
      In one of the two places it was used, the comments already had to
      explain what it did, whereas now the code matches the comment nicely.
      32946220
    • Duncan Coutts's avatar
      Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function · 664b034b
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      These are the macros originaly from Scheduler.h, previously moved to
      IOManager.h, and now replaced with a single inline function
      anyPendingTimeoutsOrIO(). We can use a single function since the two
      macros were always checked together.
      
      Note that since anyPendingTimeoutsOrIO is defined for all IO manager
      cases, including threaded, we do not need to guard its use by cpp
       #if !defined(THREADED_RTS)
      664b034b
    • Duncan Coutts's avatar
      Move macros for checking for pending IO or timers · 39a91f60
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      from Schedule.h to Schedule.c and IOManager.h
      
      This is just moving, the next step will be to rejig them slightly.
      
      For the non-threaded RTS the scheduler needs to be able to test for
      there being pending I/O operation or pending timers. The implementation
      of these tests should really be considered to be part of the I/O
      managers and not part of the scheduler.
      39a91f60
    • Duncan Coutts's avatar
      Remove the now-unused markScheduler · 0f68919e
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      The global vars {blocked,sleeping}_queue are now in the Capability and
      so get marked there via markCapabilityIOManager.
      0f68919e
    • Duncan Coutts's avatar
      Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager · ced9acdb
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      The blocked_queue_{hd,tl} and the sleeping_queue are currently
      cooperatively managed between the scheduler and (some but not all of)
      the non-threaded I/O manager implementations.
      
      They lived as global vars with the scheduler, but are poked by I/O
      primops and the I/O manager backends.
      
      This patch is a step on the path towards making the management of I/O or
      timer blocking belong to the I/O managers and not the scheduler.
      
      Specifically, this patch moves the {blocked,sleeping}_queue from being
      global vars in the scheduler to being members of the CapIOManager struct
      within each Capability. They are not yet exclusively used by the I/O
      managers: they are still poked from a couple other places, notably in
      the scheduler before calling awaitEvent.
      ced9acdb
    • Duncan Coutts's avatar
      Move APPEND_TO_BLOCKED_QUEUE from cmm to C · 5cf709c5
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      The I/O and delay blocking primitives for the non-threaded way
      currently access the blocked_queue and sleeping_queue directly.
      
      We want to move where those queues are to make their ownership clearer:
      to have them clearly belong to the I/O manager impls rather than to the
      scheduler. Ultimately we will want to change their representation too.
      
      It's inconvenient to do that if these queues are accessed directly from
      cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a
      C version appendToIOBlockedQueue(), and replace the open-coded
      sleeping_queue insertion with insertIntoSleepingQueue().
      5cf709c5
    • Duncan Coutts's avatar
      Add hook markCapabilityIOManager · 8901285e
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      To allow I/O managers to have GC roots in the Capability, within the
      CapIOManager structure.
      
      Not yet used in this patch.
      8901285e
    • Duncan Coutts's avatar
      Introduce CapIOManager as the per-cap I/O mangager state · 8d6aaa49
      Duncan Coutts authored and Marge Bot's avatar Marge Bot committed
      Rather than each I/O manager adding things into the Capability structure
      ad-hoc, we should have a common CapIOManager iomgr member of the
      Capability structure, with a common interface to initialise etc.
      
      The content of the CapIOManager struct will be defined differently for
      each I/O manager implementation. Eventually we should be able to have
      the CapIOManager be opaque to the rest of the RTS, and known just to the
      I/O manager implementation. We plan for that by making the Capability
      contain a pointer to the CapIOManager rather than containing the
      structure directly.
      
      Initially just move the Unix threaded I/O manager's control FD.
      8d6aaa49
  2. Nov 20, 2022
  3. Nov 19, 2022
  4. Nov 16, 2022
  5. Nov 15, 2022
  6. Nov 14, 2022
    • Madeline Haraj's avatar
      Implement UNPACK support for sum types. · 2b7d5ccc
      Madeline Haraj authored and Andreas Klebinger's avatar Andreas Klebinger committed
      This is based on osa's unpack_sums PR from ages past.
      
      The meat of the patch is implemented in dataConArgUnpackSum
      and described in Note [UNPACK for sum types].
      2b7d5ccc
    • Matthew Pickering's avatar
      testsuite: Improve output from tests which have failing pre_cmd · 8f6c576b
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      There are two changes:
      
      * If a pre_cmd fails, then don't attempt to run the test.
      * If a pre_cmd fails, then print the stdout and stderr from running that
        command (which hopefully has a nice error message).
      
      For example:
      
      ```
      =====> 1 of 1 [0, 0, 0]
      *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2
      ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}".
      stdout:
      stderr:
      DefaultLifted.hs:19:13: error: [GHC-76037]
          Not in scope: type constructor or class ‘Typ’
          Suggested fix:
            Perhaps use one of these:
              ‘Type’ (imported from GHC.Tc.Utils.TcType),
              data constructor ‘Type’ (imported from GHC.Plugins)
         |
      19 | instance Eq Typ where
         |             ^^^
      make: *** [Makefile:17: package.test-defaulting-plugin] Error 1
      
      Performance Metrics (test environment: local):
      ```
      
      Fixes #22329
      8f6c576b
    • Matthew Pickering's avatar
      testsuite: Add tests for T22347 · d91db679
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      These are fixed in recent versions but might as well add regression
      tests.
      
      See #22347
      d91db679
    • Ben Gamari's avatar
      eventlog: Ensure that IPE output contains actual info table pointers · 268a3ce9
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      The refactoring in 866c736e introduced a rather subtle change in the
      semantics of the IPE eventlog output, changing the eventlog field from
      encoding info table pointers to "TNTC pointers" (which point to entry
      code when tables-next-to-code is enabled). Fix this.
      
      Fixes #22452.
      268a3ce9
  7. Nov 12, 2022
  8. Nov 11, 2022
    • Simon Peyton Jones's avatar
      360f5fec
    • Simon Peyton Jones's avatar
      Type vs Constraint: finally nailed · 778c6adc
      Simon Peyton Jones authored and Simon Peyton Jones's avatar Simon Peyton Jones committed
      This big patch addresses the rats-nest of issues that have plagued
      us for years, about the relationship between Type and Constraint.
      See #11715/#21623.
      
      The main payload of the patch is:
      * To introduce CONSTRAINT :: RuntimeRep -> Type
      * To make TYPE and CONSTRAINT distinct throughout the compiler
      
      Two overview Notes in GHC.Builtin.Types.Prim
      
      * Note [TYPE and CONSTRAINT]
      
      * Note [Type and Constraint are not apart]
        This is the main complication.
      
      The specifics
      
      * New primitive types (GHC.Builtin.Types.Prim)
        - CONSTRAINT
        - ctArrowTyCon (=>)
        - tcArrowTyCon (-=>)
        - ccArrowTyCon (==>)
        - funTyCon     FUN     -- Not new
        See Note [Function type constructors and FunTy]
        and Note [TYPE and CONSTRAINT]
      
      * GHC.Builtin.Types:
        - New type Constraint = CONSTRAINT LiftedRep
        - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
      
      * Exploit the fact that Type and Constraint are distinct throughout GHC
        - Get rid of tcView in favour of coreView.
        - Many tcXX functions become XX functions.
          e.g. tcGetCastedTyVar --> getCastedTyVar
      
      * Kill off Note [ForAllTy and typechecker equality], in (old)
        GHC.Tc.Solver.Canonical.  It said that typechecker-equality should ignore
        the specified/inferred distinction when comparein two ForAllTys.  But
        that wsa only weakly supported and (worse) implies that we need a separate
        typechecker equality, different from core equality. No no no.
      
      * GHC.Core.TyCon: kill off FunTyCon in data TyCon.  There was no need for it,
        and anyway now we have four of them!
      
      * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
        See Note [FunCo] in that module.
      
      * GHC.Core.Type.  Lots and lots of changes driven by adding CONSTRAINT.
        The key new function is sORTKind_maybe; most other changes are built
        on top of that.
      
        See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.
      
      * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
        kinding ForAllTys.  See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
        (The bug was that before (forall (cv::t1 ~# t2). blah), where
        blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
        (TYPE LiftedRep).  See Note [Kinding rules for types] in GHC.Core.Type.
      
      * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
        Of course, no tcEqType any more.
      
      * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
        tyConsOfType, visVarsOfType, and occCheckExpand.  Refactoring only.
      
      * GHC.Builtin.Types.  Compiletely re-engineer boxingDataCon_maybe to
        have one for each /RuntimeRep/, rather than one for each /Type/.
        This dramatically widens the range of types we can auto-box.
        See Note [Boxing constructors] in GHC.Builtin.Types
        The boxing types themselves are declared in library ghc-prim:GHC.Types.
      
        GHC.Core.Make.  Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
        etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
        types of kind Constraint. That allows the desugaring for arrows to work;
        it gathers up free variables (including dictionaries) into tuples.
        See  Note [Big tuples] in GHC.Core.Make.
      
        There is still work to do here: #22336. But things are better than
        before.
      
      * GHC.Core.Make.  We need two absent-error Ids, aBSENT_ERROR_ID for types of
        kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
        Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
        see Note [inlineId magic].
      
      * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion.  It is now called
        SelCo, and its fields are much more descriptive than the single Int we used to
        have.  A great improvement.  See Note [SelCo] in GHC.Core.TyCo.Rep.
      
      * GHC.Core.RoughMap.roughMatchTyConName.  Collapse TYPE and CONSTRAINT to
        a single TyCon, so that the rough-map does not distinguish them.
      
      * GHC.Core.DataCon
        - Mainly just improve documentation
      
      * Some significant renamings:
        GHC.Core.Multiplicity: Many -->  ManyTy (easier to grep for)
                               One  -->  OneTy
        GHC.Core.TyCo.Rep TyCoBinder      -->   GHC.Core.Var.PiTyBinder
        GHC.Core.Var      TyCoVarBinder   -->   ForAllTyBinder
                          AnonArgFlag     -->   FunTyFlag
                          ArgFlag         -->   ForAllTyFlag
        GHC.Core.TyCon    TyConTyCoBinder --> TyConPiTyBinder
        Many functions are renamed in consequence
        e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc
      
      * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
          data FunTyFlag
            = FTF_T_T           -- (->)  Type -> Type
            | FTF_T_C           -- (-=>) Type -> Constraint
            | FTF_C_T           -- (=>)  Constraint -> Type
            | FTF_C_C           -- (==>) Constraint -> Constraint
      
      * GHC.Tc.Errors.Ppr.  Some significant refactoring in the TypeEqMisMatch case
        of pprMismatchMsg.
      
      * I made the tyConUnique field of TyCon strict, because I
        saw code with lots of silly eval's.  That revealed that
        GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
        we pack the sum tag into a 6-bit field.  (Lurking bug squashed.)
      
      Fixes
      * #21530
      
      Updates haddock submodule slightly.
      
      Performance changes
      ~~~~~~~~~~~~~~~~~~~
      I was worried that compile times would get worse, but after
      some careful profiling we are down to a geometric mean 0.1%
      increase in allocation (in perf/compiler).  That seems fine.
      
      There is a big runtime improvement in T10359
      
      Metric Decrease:
          LargeRecord
          MultiLayerModulesTH_OneShot
          T13386
          T13719
      Metric Increase:
          T8095
      778c6adc
    • Simon Peyton Jones's avatar
      Fix fragile RULE setup in GHC.Float · 154c70f6
      Simon Peyton Jones authored and Simon Peyton Jones's avatar Simon Peyton Jones committed
      In testing my type-vs-constraint patch I found that the handling
      of Natural literals was very fragile -- and I somehow tripped that
      fragility in my work.
      
      So this patch fixes the fragility.
      See Note [realToFrac natural-to-float]
      
      This made a big (9%) difference in one existing test in
      perf/should_run/T1-359
      
      Metric Decrease:
          T10359
      154c70f6
    • Matthew Craven's avatar
      Weaken wrinkle 1 of Note [Scrutinee Constant Folding] · 6b92b47f
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      
      Fixes #22375.
      
      Co-authored-by: default avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
      6b92b47f
    • Krzysztof Gogolewski's avatar
      Use a more efficient printer for code generation (#21853) · 3c37d30b
      Krzysztof Gogolewski authored
      
      The changes in `GHC.Utils.Outputable` are the bulk of the patch
      and drive the rest.
      The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc`
      and support printing directly to a handle with `bPutHDoc`.
      See Note [SDoc versus HDoc] and Note [HLine versus HDoc].
      
      The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic
      over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF
      and dependencies (printing module names, labels etc.).
      
      Co-authored-by: default avatarAlexis King <lexi.lambda@gmail.com>
      
      Metric Decrease:
          CoOpt_Read
          ManyAlternatives
          ManyConstructors
          T10421
          T12425
          T12707
          T13035
          T13056
          T13253
          T13379
          T18140
          T18282
          T18698a
          T18698b
          T1969
          T20049
          T21839c
          T21839r
          T3064
          T3294
          T4801
          T5321FD
          T5321Fun
          T5631
          T6048
          T783
          T9198
          T9233
      3c37d30b
    • Simon Peyton Jones's avatar
      Add a fast path for data constructor workers · d0c691b6
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      See Note [Fast path for data constructors] in
      GHC.Core.Opt.Simplify.Iteration
      
      This bypasses lots of expensive logic, in the special case of
      applications of data constructors.  It is a surprisingly worthwhile
      improvement, as you can see in the figures below.
      
      Metrics: compile_time/bytes allocated
      ------------------------------------------------
                CoOpt_Read(normal)   -2.0%
          CoOpt_Singletons(normal)   -2.0%
          ManyConstructors(normal)   -1.3%
                    T10421(normal)   -1.9% GOOD
                   T10421a(normal)   -1.5%
                    T10858(normal)   -1.6%
                    T11545(normal)   -1.7%
                    T12234(optasm)   -1.3%
                    T12425(optasm)   -1.9% GOOD
                    T13035(normal)   -1.0% GOOD
                    T13056(optasm)   -1.8%
                    T13253(normal)   -3.3% GOOD
                    T15164(normal)   -1.7%
                    T15304(normal)   -3.4%
                    T15630(normal)   -2.8%
                    T16577(normal)   -4.3% GOOD
                    T17096(normal)   -1.1%
                    T17516(normal)   -3.1%
                    T18282(normal)   -1.9%
                    T18304(normal)   -1.2%
                   T18698a(normal)   -1.2% GOOD
                   T18698b(normal)   -1.5% GOOD
                    T18923(normal)   -1.3%
                     T1969(normal)   -1.3% GOOD
                    T19695(normal)   -4.4% GOOD
                   T21839c(normal)   -2.7% GOOD
                   T21839r(normal)   -2.7% GOOD
                     T4801(normal)   -3.8% GOOD
                     T5642(normal)   -3.1% GOOD
                     T6048(optasm)   -2.5% GOOD
                     T9020(optasm)   -2.7% GOOD
                     T9630(normal)   -2.1% GOOD
                     T9961(normal)  -11.7% GOOD
                     WWRec(normal)   -1.0%
      
                         geo. mean   -1.1%
                         minimum    -11.7%
                         maximum     +0.1%
      
      Metric Decrease:
          T10421
          T12425
          T13035
          T13253
          T16577
          T18698a
          T18698b
          T1969
          T19695
          T21839c
          T21839r
          T4801
          T5642
          T6048
          T9020
          T9630
          T9961
      d0c691b6
    • Matthew Pickering's avatar
      driver: Fix -fdefer-diagnostics flag · 6dab0046
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      The `withDeferredDiagnostics` wrapper wasn't doing anything because the
      session it was modifying wasn't used in hsc_env. Therefore the fix is
      simple, just push the `getSession` call into the scope of
      `withDeferredDiagnostics`.
      
      Fixes #22391
      6dab0046
Loading