
#14929: Program compiled with -O2 exhibits much worse performance -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I have not looked at the code, but full laziness is definitely capable of increasing space usage. Consider even {{{ f xs = sum [x+n | n <- [1..], x <- xs] }}} Full laziness will turn this into {{{ ns = [1..] f xs = sum [x+n | n<-ns, x<-xs] }}} which will retain a top-level CAF whose length is the longest list ever passed to `f`. In this case it is probably better to re-generate the list `[1..]` on every call, but it's not so clear if it is `map expensive [1..]`. The OP doesn't say if the same effect happens with -O. Is there something -O2 specific going on, I wonder? Regardless * Extracting the test case and uploading it here with repro instructions would be good * More specific insight into exactly what is happening would be good -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14929#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler