#783: performance problem compiling large file
------------------------------------------+---------------------------------
Reporter: guest | Owner:
Type: compile-time performance bug | Status: new
Priority: normal | Milestone: 6.8.3
Component: Compiler | Version: 6.4.2
Severity: normal | Resolution:
Keywords: performance | Difficulty: Unknown
Testcase: | Architecture: Multiple
Os: Multiple |
------------------------------------------+---------------------------------
Comment (by igloo):
With a slightly simpler variant of this:
{{{
module Foo where
foo :: Double -> Int
foo x | x == 1 = 1
foo x | x == 2 = 2
...
foo x | x == 500 = 500
}}}
compiling with
{{{
ghc -c large.hs -fforce-recomp +RTS -p -h
}}}
one problem is that we get something like
{{{
lit1 = ...
lit2 = ...
...
foo = case ... of
False ->
case ... of
False -> ...
True -> lit2
True -> lit1
}}}
Each of the case expressions has an SRT for its alternatives. The outer
one has all 500 lit's, the one inside 499, and so on, so we have
quadratic space usage. The SRTs are `SRTEntries cafs`, where `cafs` is an
`IdSet` (which is ultimately a `UniqFM`), so no sharing is possible.
In this particular case using `-O` "fixes" it as `==` etc get specialised
and the lits disappear, but (a) this won't be the case in general and
(b) I don't think you should need to use `-O` to get reasonable compiler
space usage.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/783#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs