[GHC] #7258: Compiling DynFlags is jolly slow

GHC ghc-devs at haskell.org
Tue Oct 24 11:23:57 UTC 2017


#7258: Compiling DynFlags is jolly slow
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  simonpj
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  deriving-perf
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Latest profiling results:

 - graph plot: https://ghc.haskell.org/trac/ghc/attachment/ticket/7258/ghc-
 large-record-types.png
 - raw results:
 https://ghc.haskell.org/trac/ghc/attachment/ticket/7258/profiles.csv
 - example code:
 https://ghc.haskell.org/trac/ghc/attachment/ticket/7258/examples.zip

 The test module defines a record type of N fields, named `field0` through
 `field{N-1}`, called `DT`; the performance metric is the "total time"
 value from the profiler output for GHC compiling the module on its own.
 The codenames refer to different versions of the test module (all of them
 defining the same `DT` type though):

 - `nothing`: just a raw record type, no instances or functions. This is
 the baseline.
 - `show`: a derived Show instance (`deriving (Show)`)
 - `read`: a derived Read instance (`deriving (Read)`)
 - `read-appl`: a hand-written Read instance using applicative syntax (`DT
 <$> a1 <*> a2 <*> a3 <*> ...`)
 - `getline`: a hand-written function consisting of a series of N monadic
 binds followed by a `return` of an N-argument call to the `DT`
 constructor. This is the same shape as what the derived Read and Show
 instances produce internally.
 - `getline-appl`: a hand-written function that reads fields from stdin
 using `getLine` and applicatively combines them into a value of our record
 type: `DT <$> (read <$> getLine) <*> (read <$> getLine) <*> ...`
 - `getline-standalone`: a set of N functions performing one `getLine` call
 each: `getlD :: Int -> IO Int; getlD i = read <$> getLine`
 - `show-standalone`: a set of N functions, each constructing a string by
 combining an integer argument with the function's index

 The `-standalone` and `nothing` flavors were added as controls.

 Looking at the plot, the pattern is pretty obvious: the applicative
 versions show performance patterns very similar to the control, while the
 three versions that use many monadic binds all exhibit clearly nonlinear
 performance.

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


More information about the ghc-tickets mailing list