[GHC] #12150: Compile time performance degradation on code that uses undefined/error with CallStacks

GHC ghc-devs at haskell.org
Wed Jul 12 04:43:49 UTC 2017


#12150: Compile time performance degradation on code that uses undefined/error with
CallStacks
-------------------------------------+-------------------------------------
        Reporter:  thomie            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.2.2
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10844            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 OK, I have a guess about what's going on now. I didn't notice this before,
 because the shapes were similar, but there's a big difference between how
 7.10 and 8.0 handle this code in the very earliest stages. In particular,
 `-ddump-ds` for 7.10 shows that `bool` has already inlined, exposing the
 `undefined`s (which it already knows to be bottom), whereas that has not
 happened in 8.0. Presumably, the slight optimization that takes place
 along with desugaring sees `bool = undefined`, concludes that there's no
 reason to have the extra identifier, and inlines it away altogether.

 In 8.0 and 8.2, `bool` is not just `undefined`, but `undefined` ''applied
 to a dictionary''. So suddenly it needs to actually produce a `bool`
 binding, and doesn't figure out until demand analysis that `bool` is
 always bottom.

 I suspect that what we want to do is to shift just a bit of demand
 analysis way up. `undefined` has demand signature

 {{{
 <B,1*U>x
 }}}

 So we really shouldn't need to wait for full demand analysis to conclude
 that `bool` has demand signature `x`; that follows immediately. Could we
 teach the ''simplifier'' how to reduce some demand applications? Perhaps
 it should even reduce any that it sees; I'm not sure of the full
 implications of that choice.

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


More information about the ghc-tickets mailing list