[GHC] #9557: Deriving instances is slow

GHC ghc-devs at haskell.org
Sun Sep 21 23:03:19 UTC 2014


#9557: Deriving instances is slow
-------------------------------------+-------------------------------------
              Reporter:  Feuerbach   |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Compiler    |          Version:  7.8.3
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:  #8731
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 I performed the following list of modifications to the program and
 recorded the size in terms after desugaring after each step:

 ||=step=||=program size (terms)=||
 ||original|| 126396||
 ||remove everything but data decls|| 122877||
 ||remove deriving Generic|| 106339||
 ||remove deriving Data|| 78544||
 ||remove deriving Traversable|| 70886||
 ||remove deriving Foldable|| 59332||
 ||remove deriving Functor|| 55041||
 ||remove deriving Show|| 42848||
 ||remove deriving Ord|| 11044||
 ||remove deriving Eq|| 2244||
 ||remove deriving Typeable|| 1140||

 So, the cost of each class is

 ||=class=||=terms=||
 ||Ord|| 31804||
 ||Data|| 27795||
 ||Generic|| 16538||
 ||Show|| 12193||
 ||Foldable|| 11554||
 ||Eq|| 8800||
 ||Traversable|| 7658||
 ||Functor|| 4291||
 ||Typeable|| 1104||

 So no individual class is adding a particularly egregious amount of code.

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


More information about the ghc-tickets mailing list