[GHC] #15192: Refactor of Coercion

GHC ghc-devs at haskell.org
Wed Jul 4 16:26:03 UTC 2018


#15192: Refactor of Coercion
-------------------------------------+-------------------------------------
        Reporter:  ningning          |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4747
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by ningning):

 - Overall changes so far:
    1. Removed {{{Refl r ty}}} and {{{CoherenceCo}}}
    2. Introduced {{{Refl ty}}} and {{{GRefl r ty MCoercion}}}
        - {{{Refl ty :: ty ~n ty}}}, note that {{{Refl ty}}} is always
 nominal.
        - {{{GRefl r ty MRefl :: ty ~r ty}}}. If {{{r == Nominal}}}, {{{use
 Refl}}}.
        - {{{GRefl r ty (MCo co) :: ty ~r ty |>co}}}.
    3. Replaced original {{{Refl Nominal ty}}} with {{{Refl ty}}}.
    4. Given {{{g1 :: s ~r t}}}, to construct {{{s |> g2 ~r t}}} we used
 {{{CoherenceCo g1 g2}}}. It is now replaced with {{{Sym (GRefl r s g2) ;
 g1}}}. Similar for {{{s ~ t |> g3}}}.
    5. It turns out that the explicit patten match in
 {{{homogenise_result}}} in TcFlatten triggers some optimization of GHC and
 improves the performance. However it is not useful in master branch.
    6. Added a small regression for T9872d (the added number is the
 allocation of current master on T9872d).
    7. Added note about {{{flatten_exact_fam_app_fully}}} performance in
 TcFlatten.
 - Performance summary
    1. This patch intends to improve the overall performance about
 coercions.
    2. It does perform better in all cases under perf/compiler, except
 T9872b (0.6%), T9872d(3.7%), and T14683(0.02%).
    3. It failed T9872d, thus we added a small regression.
    4. It seems to perform better to compile large packages, e.g. Cabal.
 - TODO: Further analysis of the performance: a step-by-step replay of the
 refactor.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15192#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list