Code becomes slower as more boxed arrays are allocated

后端 未结 2 1032
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 17:45

Edit: It turns out that things generally (not just array/ref operations) slow down the more arrays have been created, so I guess this might just be meas

相关标签:
2条回答
  • 2021-01-07 18:20

    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.

    0 讨论(0)
  • 2021-01-07 18:21

    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

    0 讨论(0)
提交回复
热议问题