
On Sat, Jul 04, 2015 at 06:17:06AM +0000, Baojun Wang wrote:
Appreciate for the prompt reply, sorry for that I assumed the allocations was caused by space leak. I guess profiling with -auto-all really has huge impact on allocations. without profiling, haskell version runs about 50% slower than equivalent C version (both with -O2). Maybe that's as much as one could expect.
50% sounds like a good start, but I bet with some time and effort you can substantially improve on it. Specifically, the code is spending *loads* of time doing bounds checking. It checks on every array read and write. I suggest (for an experiment, not production code!) you replace the reads and writes with unsafe versions and see what speedup that gives you. I don't know how to do unsafe reads and writes with the array library, but for vectors the API is here: http://hackage.haskell.org/package/vector-0.10.12.3/docs/Data-Vector-Mutable... Tom