[GHC] #12996: Memory leak in recursion when switching from -O1 to -O2

GHC ghc-devs at haskell.org
Sat Dec 17 14:17:29 UTC 2016


#12996: Memory leak in recursion when switching from -O1 to -O2
-------------------------------------+-------------------------------------
        Reporter:  AndreasK          |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  Memory leak,
                                     |  optimization
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:                    |
-------------------------------------+-------------------------------------
Description changed by AndreasK:

@@ -24,0 +24,4 @@
+
+ The stg output seems to be the same for both cases as well. I attached STG
+ dumps created with " -fforce-recomp -ddump-to-file -dverbose-core2core
+ -dsuppress-uniques -dsuppress-all Main.hs -ddump-simpl -dverbose-stg2stg"

New description:

 For example code see attachment.

 When compiling with -O1 the code behaves as expected with each loop taking
 about the same amount of time.

 At -O2 each iteration takes (nonlinear) more time than the last and leaks
 memory. It gets slow enough that I never bothered to let it run past 40
 iterations since the slowdown seems to be exponential.

 I initially hit the bug in code using a Set instead of list but turns out
 the issue can be reduced to an example with lists.

 Removing either filter, pattern matching or changing the loop fixes the
 issue.

 I tested it under the following conditions:

 * Compiler flags: -fno-full-laziness/No flags
 * Compiler versions: GHC 8.0.1 and 7.10.3e
 * Operating Systems: Windows 10, Linux Mint

 In every case -O1 works as expected with -O2 showing exponential slowdown
 with each iteration.

 The stg output seems to be the same for both cases as well. I attached STG
 dumps created with " -fforce-recomp -ddump-to-file -dverbose-core2core
 -dsuppress-uniques -dsuppress-all Main.hs -ddump-simpl -dverbose-stg2stg"

--

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


More information about the ghc-tickets mailing list