Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: pcapriotti Type: bug | Status: closed Priority: high | Milestone: 7.6.1 Component: libraries/base |Version: 7.0.3 Resolution: fixed| Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: T5205| Blockedby: Blocking: |Related: --+- Changes (by pcapriotti): * status: merge = closed * resolution: = fixed Comment: Merged as ef4218994742e8400a48b4d6e1ae7e6b67650dc4. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: pcapriotti Type: bug | Status: new Priority: high | Milestone: 7.6.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: T5205| Blockedby: Blocking: |Related: --+- Changes (by simonmar): * priority: normal = high * milestone: 7.2.1 = 7.6.1 Comment: Moving to an active milestone. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: pcapriotti Type: bug | Status: merge Priority: high | Milestone: 7.6.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: T5205| Blockedby: Blocking: |Related: --+- Changes (by pcapriotti): * status: new = merge Comment: Pushed: {{{ commit f55f5574c12ff8dfe57994219eee0702ac8aba2e Author: Paolo Capriotti p.caprio...@gmail.com Date: Mon Aug 20 16:35:38 2012 +0100 Improve definition of forever (#5205) The previous implementation was: forever a = a forever a which can create a space leak in some cases, even with optimizations. The current implementation: forever a = let a' = a a' in a' prevents repeated thunk allocations by creating a single thunk for the final result, even without optimizations. }}} I also removed the note and a `SPECIALISE` pragma in GHC.ST. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: pcapriotti Type: bug | Status: new Priority: normal | Milestone: 7.2.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: T5205| Blockedby: Blocking: |Related: --+- Changes (by Khudyakov): * cc: alexey.skladnoy@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.2.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Testcase: | Blockedby: Blocking: |Related: --+- Changes (by edsko): * owner: igloo = * status: closed = new * resolution: fixed = Comment: I have an example with a space leak (according to +RTS -hy) due to forever when compiled with -prof -fauto-all -O1 and when compiled with -prof -fprof-auto -O2, but not when compiled with -prof -fprof-auto -O0 for some bizarre reason. When I remove the -prof -fprof-auto and profile with +RTS -hT the space leak disappears for any optimization level. I have tried to minimize the example but failed so far, unfortunately. However, the following alternative definition of forever doesn't have a space leak with any compiler flags: {{{ forever a = let a' = a a' in a' }}} Is there a good reason why this definition is not used? It seems less reliant on optimization to avoid the space leak. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: igloo Type: bug | Status: new Priority: normal | Milestone: 7.2.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Changes (by simonpj): * owner: = igloo * difficulty: = Unknown Comment: Actually that makes a lot of sense. Ian or Paolo, would you like to change the definition of 'forever' as edsko suggests, and check it's ok with your performance test. Ian: you say that you added a test, but you didn't say what the test is on this ticket, so maybe you can do that too? (Thinking about it, I'm really not sure what difference it makes to make the current recursive defn of `forever` INLINABLE. The comment doesn't explain! But if we change the definition it becomes moot anyway.) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: pcapriotti Type: bug | Status: new Priority: normal | Milestone: 7.2.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: | Blockedby: Blocking: |Related: --+- Changes (by pcapriotti): * owner: igloo = pcapriotti -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: pcapriotti Type: bug | Status: new Priority: normal | Milestone: 7.2.1 Component: libraries/base |Version: 7.0.3 Resolution: | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Runtime performance bug | Difficulty: Unknown Testcase: T5205| Blockedby: Blocking: |Related: --+- Changes (by igloo): * testcase: = T5205 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space --+- Reporter: akio | Owner: igloo Type: bug | Status: closed Priority: normal | Milestone: 7.2.1 Component: libraries/base |Version: 7.0.3 Resolution: fixed| Keywords: Testcase: | Blockedby: Difficulty: | Os: Unknown/Multiple Blocking: | Architecture: Unknown/Multiple Failure: Runtime performance bug | --+- Changes (by igloo): * status: new = closed * resolution: = fixed Comment: Test added. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio |Owner: igloo Type: bug | Status: new Priority: normal|Milestone: 7.2.1 Component: libraries/base| Version: 7.0.3 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Comment(by simonpj): Ian: all we need is a perf test for this, and we can close it. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio |Owner: igloo Type: bug | Status: new Priority: normal|Milestone: 7.2.1 Component: libraries/base| Version: 7.0.3 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Changes (by igloo): * priority: highest = normal -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio |Owner: simonpj Type: bug | Status: new Priority: highest |Milestone: 7.2.1 Component: libraries/base| Version: 7.0.3 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Changes (by simonmar): * owner: igloo = simonpj Comment: Ok, we looked at this, and it turns out that 6.12.3 desugars `forever` differently: in 6.12, a local recursive `let` was introduced, which meant that `forever` could be inlined (and hence specialised) at every call site, whereas in 7.0 the desugarer leaves the function as a top-level recursive function which cannot be inlined. The solution is to add an `INLINABLE` pragma for `forever`, which will allow it to be specialised at a call site. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio |Owner: igloo Type: bug | Status: new Priority: highest |Milestone: 7.2.1 Component: libraries/base| Version: 7.0.3 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Changes (by simonpj): * owner: simonpj = igloo Comment: I've made 'forever' INLINABLE, and added a SPECIALISE pragma in GHC.ST. {{{ commit ae10342b49b95393b09ffee8df8c847409699968 Author: Simon Peyton Jones simo...@microsoft.com Date: Thu Jun 9 20:44:21 2011 +0100 Make 'forever' inlinable (fixes Trac #5205) See Note [Make forever INLINABLE] in Control.Monad --- Control/Monad.hs | 18 ++ GHC/ST.lhs |4 2 files changed, 22 insertions(+), 0 deletions(-) }}} That fixes the bug, but only with `-O`. Without `-O` you still get the leak, and I don't really think its unreasonable. You have {{{ x = forever (return ()) }}} which expands to {{{ x = return () return () return () etc }}} If `()` was expensive when applied to two args, then it'd be right to hang onto the computed result. In the case of IO it isn't expensive, and it's best to recompute (and save space) but only the optimiser can reveal that. Ian: can you add a perf/ test please, then close? Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio |Owner: igloo Type: bug | Status: new Priority: highest |Milestone: 7.2.1 Component: libraries/base| Version: 7.0.3 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Changes (by liyang): * cc: hackage.haskell.org@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio |Owner: igloo Type: bug | Status: new Priority: highest |Milestone: 7.2.1 Component: libraries/base| Version: 7.0.3 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Changes (by igloo): * owner: = igloo * priority: normal = highest * milestone: = 7.2.1 Comment: Thanks for the report. I'll take a look. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #5205: Control.Monad.forever leaks space
#5205: Control.Monad.forever leaks space -+-- Reporter: akio | Owner: Type: bug | Status: new Priority: normal| Component: libraries/base Version: 7.0.3 |Keywords: Testcase:| Blockedby: Os: Unknown/Multiple |Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- The attached program, compiled with GHC 7.0.3, uses up all the memory. It runs in a constant space when compiled with GHC 6.12.3. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5205 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs