[GHC] #9198: large performance regression in type checker speed in 7.8

GHC ghc-devs at haskell.org
Sat Jan 9 18:45:22 UTC 2016


#9198: large performance regression in type checker speed in 7.8
-------------------------------------+-------------------------------------
        Reporter:  carter            |                Owner:
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.2.1
       Component:  Compiler (Type    |              Version:  7.8.2
  checker)                           |
      Resolution:                    |             Keywords:
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:                    |
-------------------------------------+-------------------------------------
Changes (by bgamari):

 * milestone:  8.0.1 => 8.2.1


Old description:

> it was recently demonstrated on the haskell-cafe mailing list that  the
> following code takes measurably longer to type check in GHC 7.8.2 than in
> GHC  7.6.
>
> http://www.haskell.org/pipermail/haskell-cafe/2014-June/114562.html
>

> the program example is as follows
> {{{
> begin :: Monad m => (m () -> t) -> t
> begin cont = cont (return ())
>
> a :: IO a -> (IO () -> t) -> t
> a m cont = cont (m >> putStrLn "a")
>
> end :: t -> t
> end m = m
>
> main = begin a a a a a a a a a a a a a a a a a a end
> }}}
> takes about a second to type check in ghc 7.8, and is "instant" in 7.6 ()
>
> each additional a doubles the time to type check the program
>
> {{{
> main = begin a a a a a a a a a a a a a a a a a a a a a a a a end
> }}}
>
> takes longer than I have the patience to wait :) (so more than 5 seconds)
>
> the author of the email notes that a related program
>
> {{{
>   main = id id id id id id id id id id id
>          id id id id id id id id id id id (return ())
> }}}
> has the exponential complexity in both 7.8.2 and 7.6.2
>
> This It could very well be that some of the type checker changes between
> 7.8 and 7.6 enlarged the space of programs that trip up exponential worst
> case behavior, but one way or another understanding *why* this happened

New description:

 it was recently demonstrated on the haskell-cafe mailing list that  the
 following code takes measurably longer to type check in GHC 7.8.2 than in
 GHC  7.6.

 http://www.haskell.org/pipermail/haskell-cafe/2014-June/114562.html


 the program example is as follows
 {{{#!hs
 begin :: Monad m => (m () -> t) -> t
 begin cont = cont (return ())

 a :: IO a -> (IO () -> t) -> t
 a m cont = cont (m >> putStrLn "a")

 end :: t -> t
 end m = m

 main = begin a a a a a a a a a a a a a a a a a a end
 }}}
 takes about a second to type check in ghc 7.8, and is "instant" in 7.6 ()

 each additional a doubles the time to type check the program

 {{{#!hs
 main = begin a a a a a a a a a a a a a a a a a a a a a a a a end
 }}}

 takes longer than I have the patience to wait :) (so more than 5 seconds)

 the author of the email notes that a related program

 {{{#!hs
   main = id id id id id id id id id id id
          id id id id id id id id id id id (return ())
 }}}
 has the exponential complexity in both 7.8.2 and 7.6.2

 This It could very well be that some of the type checker changes between
 7.8 and 7.6 enlarged the space of programs that trip up exponential worst
 case behavior, but one way or another understanding *why* this happened

--

Comment:

 This won't be fixed for 8.0.1.

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


More information about the ghc-tickets mailing list