[GHC] #5642: Deriving Generic of a big type takes a long time and lots of space

GHC ghc-devs at haskell.org
Sat Jun 18 22:23:21 UTC 2016


#5642: Deriving Generic of a big type takes a long time and lots of space
-------------------------------------+-------------------------------------
        Reporter:  basvandijk        |                Owner:  bgamari
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.3
      Resolution:                    |             Keywords:  deriving-
                                     |  perf, Generics
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:  T5642
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D2304
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"9649fc0ae45e006c2ed54cc5ea2414158949fadb/ghc"
 9649fc0a/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="9649fc0ae45e006c2ed54cc5ea2414158949fadb"
 Refactor derived Generic instances to reduce allocations

 Previously, derived implementations of `to`/`from` in `Generic`
 instances were wastefully putting extra `M1`s in every case, which led
 to an O(n) increase in the number of coercions, resulting in a slowdown
 during the typechecker phase.

 This factors out the common `M1` in every case of a `to`/`from`
 definition so that the typechecker has far fewer coercions to deal with.
 For a datatype with 300 constructors, this change has been observed to
 save almost 3 seconds of compilation time.

 This is one step towards coming up with a solution for #5642.

 Test Plan: ./validate

 Reviewers: hvr, austin, simonpj, bgamari

 Reviewed By: bgamari

 Subscribers: basvandijk, carter, thomie, osa1

 Differential Revision: https://phabricator.haskell.org/D2304

 GHC Trac Issues: #5642
 }}}

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


More information about the ghc-tickets mailing list