Code becomes slower as more boxed arrays are allocated Code becomes slower as more boxed arrays are allocated arrays arrays

Code becomes slower as more boxed arrays are allocated


You are paying linear overhead every minor GC per mutable array that remains live and gets promoted to the old generation. This is because GHC unconditionally places all mutable arrays on the mutable list and traverses the entire list every minor GC. See https://ghc.haskell.org/trac/ghc/ticket/7662 for more information, as well as my mailing list response to your question: http://www.haskell.org/pipermail/glasgow-haskell-users/2014-May/024976.html


I think you're definitely seeing GC effects. I had a related issue in cassava (https://github.com/tibbe/cassava/issues/49#issuecomment-34929984) where the GC time was increasing linearly with increasing heap size.

Try to measure how the GC time and mutator time increase as you hold on to more and more arrays in memory.

You can reduce GC time with playing with the +RTS options. For example, try setting -A to your L3 cache size.