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.

On Fri, Jul 3, 2015 at 2:41 PM Tom Ellis <tom-lists-haskell-cafe-2013@jaguarpaw.co.uk> wrote:
On Fri, Jul 03, 2015 at 06:00:48PM +0000, Baojun Wang wrote:
> My concerns is ~80% alloc happens in f3, but both array is allocated by
> newArray? Since I'm using unboxed array I'm not expecting this kind of
> laziness.

I see.  You seem to be asking why it is allocating *at all*.  That's not
a phenomenon that normally falls under the terminology of "space leak",
hence my confusion.

I'm not an expert at reading Core, but I spent some time looking at it
without seeing anywhere that would obviously allocate a lot.  Eventually I
decided to supply the profiling options to ghc-core and lo and behold the
output changed dramatically!

Unless I am very much misunderstanding how cost centre annotations work, the
amount of allocation without -auto-all is only 10% of the amount with it.
Please check and let me know if you concur that it is the profiling itself
that is the root cause of all the allocation!

Tom
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe