- Lots of calls to
stg_newArray, undoubtedly due to theCellListvector getting copied bymodify. The documentation says thatmodifycan update destructively, but I am pretty sure that this only refers to situations where the sourceVectorcan be derived to be a temporary value available for fusion.Lots of calls to
stg_newArray, undoubtedly due to theCellListvector getting copied bymodify. The documentation says thatmodifycan update destructively, but I am pretty sure that this only refers to situations where the sourceVectorcan be derived to be a temporary value available for fusion.To really get destructive updates, you would probably have to explicitly use a
MVectorand theSTmonad. As you already have a monad around, the amount of refactoring involved wouldn't be crushing, but you would obviously lose a bit of purity. Additionally, the
neighbours,getCellandcellNeighboursfunctions are getting hammered by your program. You are doing some pretty fancy list processing in there that GHC seems to not optimize very well - pretty much all these lists are actually generated and consumed. Helping GHC a bit by spelling out the loops might improve things.Finally, the default random number generator is slow - any time you use it you get a flurry of
Integerallocations behind the scenes. Try to find a better one on Hackage.
To really get destructive updates, you would probably have to explicitly use a MVector and the ST monad. As you already have a monad around, the amount of refactoring involved wouldn't be crushing, but you would obviously lose a bit of purity.
Additionally, the
neighbours,getCellandcellNeighboursfunctions are getting hammered by your program. You are doing some pretty fancy list processing in there that GHC seems to not optimize very well - pretty much all these lists are actually generated and consumed. Helping GHC a bit by spelling out the loops might improve things.Finally, the default random number generator is slow - any time you use it you get a flurry of
Integerallocations behind the scenes. Try to find a better one on Hackage.