Changes between Version 12 and Version 13 of NestedCPR


Ignore:
Timestamp:
Jan 7, 2014 10:20:40 AM (19 months ago)
Author:
nomeata
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NestedCPR

    v12 v13  
    2222 * Look at !DmdAnal-related [SLPJ-Tickets] and see which ones are affected by nested-cpr.
    2323 * Do not destroy join points (see below).
    24  * Can we make sure more stuff gets the `Terminating` flag, e.g. after a `case` of an unboxed value?
     24 * Can we make sure more stuff gets the `Converging` flag, e.g. after a `case` of an unboxed value? Should case binders get the `Converging` flag? What pattern match variables in strict data constructors? Unboxed values?
    2525
    26 ==== join points ====
     26=== join points ===
    2727
    28 CPR can kill join points. Idea to fix this, and possibly more general benefits:
     28CPR can kill join points.
     29
     30==== Common Context ====
     31
     32Idea to fix this, and possibly more general benefits:
    2933http://www.haskell.org/pipermail/ghc-devs/2013-December/003481.html; prototype in branch `wip/common-context`.
    3034
    3135 * On its own, improvements are present but very small: http://www.haskell.org/pipermail/ghc-devs/2013-December/003500.html
    3236 * Enabling CPR for sum types in non-top-level-bindings (which is currently disabled due to worries abut lost join points) yields mixed results (min -3.8%, mean -0.0%, max 3.4%).
    33  * Enabling nested CPR in inside sum types also yields mixed, not very promising results (-6.9% / +0.0% / +11.3%).
     37 * Enabling sum types inside nested CPR: Also yields mixed, not very promising results (-6.9% / +0.0% / +11.3%).
     38
     39==== Direct detection ====
    3440
    3541Alternative: Detect join points during `dmdAnal` and make sure that their CPR info is not greater than that of the expression they are a join-point for. Would also fix #5075, see [ticket:5075#comment:19] for benchmark numbers.
    3642
    37 
    38 ==== better-ho-cardinality ====
    39 
    40 It would be nice to merge the code structure improvements and notes into master, to keep my branch short. But it is based on `better-ho-cardinality`, and that is not suitable for merging because of unexpected regressions even in `nofib` and `rtak`. So I am investigating.
    41 
    42 In these tests, it is related to reading and showing data. Small example:
    43 {{{
    44 #!haskell
    45 main = (read "10" :: Int) `seq` return ()
    46 }}}
    47 Baseline: 49832, `better-ho-cardinality`: 49968. Unfortunately, the changes to, for example, `GHC.Read` are not small, and probably mostly benign...
    48 
    49 Trying to minimize and isolate the problem. After some aggressive code deleting, this is where I ended up:
    50 {{{
    51 #!haskell
    52 {-# LANGUAGE RankNTypes #-}
    53 
    54 data P a
    55   = Get (Char -> P a)
    56   | Result a
    57 
    58 Get f1     `mplus` Get f2     = undefined
    59 Result x   `mplus` _          = Result x
    60 
    61 newtype ReadP a = R (forall b . (a -> P b) -> P b)
    62 
    63 instance Monad ReadP where
    64   return x  = R (\k -> k x)
    65   R m >>= f = R (\k -> m (\a -> let R m' = f a in m' k))
    66 
    67 readP_to_S (R f) = f Result `seq` ()
    68 
    69 ppp :: ReadP a -> ReadP a -> ReadP a
    70 ppp (R f1) (R f2) = R (\k -> f1 k `mplus` f2 k)
    71 
    72 paren :: ReadP () -> ReadP ()
    73 paren p = p >> return ()
    74 
    75 parens :: ReadP () -> ReadP ()
    76 parens p = optional
    77  where
    78   optional  = ppp p mandatory
    79   mandatory = paren optional
    80 
    81 foo = paren ( return () )
    82 
    83 foo2 = ppp (parens ( return () )) (parens (return ()))
    84 
    85 main = readP_to_S foo `seq` readP_to_S foo2 `seq` return ()
    86 }}}
    87 it is important that both `paren` and `parens` are used more than once; if there is only one use-site, the problem disappears (which made it hard to find). Also, most other changes prevent the increase in allocations: Removing the `Monad` instance and turning its methods into regular functions; adding `NOINLINE` annotations to `paren` or `parens`; changing `foo2` to `ppp foo foo`; even removing the dead code that is the first line of the `mplus` function.
    88 
    89 Further investigation and aggresive patch-splitting shows that the arity change is causing the regression. Pushed everything but that patch to master, that patch now lives in `wip/exprArity`.
     43 * On its own, no changes.
     44 * Enabling CPR for sumtypes: (min -3.8%, mean -0.0%, max 1.7%) (slightly better than with Common Context)
     45 * Enabling sum types inside nested CPR: TBD
    9046
    9147=== Side tracks ===
     
    9450 * Can we use `Terminates` CPR information to eagerly evaluate thunks? Yes, and there is a small gain there: #8655
    9551 * Why is `cacheprof` not deterministic? (→ #8611)
     52 * What became of Simon’s better-ho-cardinality branch? See [./better-ho-cardinality].