Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-09 Thread Chris Yuen
Hi all, Thanks Bryan, reading your clean code was good for my Haskell health :) I took your code and did some more research. I think I have found the answer. I have written an extensive analysis in my blog post http://cfc.kizzx2.com/index.php/in-search-of-performance-in-haskell/(comments are

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-09 Thread Johan Tibell
Hi Chris, On Tue, Aug 9, 2011 at 12:47 PM, Chris Yuen kizzx2+hask...@gmail.com wrote: 1. Why are bangs needed on the length arrays? If I remove them from below, performance drops 10%. I thought `unsafeIndex` is straight in both arguments, no? wordLength i = go i   where     go n   |

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-09 Thread Bryan O'Sullivan
On Tue, Aug 9, 2011 at 9:47 AM, Chris Yuen kizzx2+hask...@gmail.com wrote: - I was using GHC 32-bit. Int is 32-bit there, so I needed Int64. It turns out 64-bit operations in 32-bit programs are just darn slow. Maybe it's a Windows problem. No, GHC calls out to C for 64-bit integer ops on

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-09 Thread Chris Yuen
It's cheaper again to use quotInt# and remInt# as I did in my code. Just want to point out that this is actually surprisingly less of an impact than I thought. As I did the step-by-step break down (you can see my blog post), this one (changing `quotRem` to `quotInt#` and `remInt#`) yielded

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-08 Thread Chris Yuen
Where is the `unsafeAt` function? I can't seem to find it ( http://haskell.org/hoogle/?hoogle=unsafeat). For reference I have asked the same question on StackOverflow. One person suggested that the reason might be that Int64 on Windows is broken (

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-08 Thread Daniel Fischer
On Monday 08 August 2011, 18:24:45, Chris Yuen wrote: Where is the `unsafeAt` function? Data.Array.Base I can't seem to find it ( http://haskell.org/hoogle/?hoogle=unsafeat). Data.Array.Base is not haddocked (there's a reason for that), so hoogle doesn't know about its functions. For

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-08 Thread Bryan O'Sullivan
On Mon, Aug 8, 2011 at 9:24 AM, Chris Yuen kizzx2+hask...@gmail.com wrote: For reference I have asked the same question on StackOverflow. One person suggested that the reason might be that Int64 on Windows is broken (

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-08 Thread Reiner Pope
On 9 August 2011 10:06, Bryan O'Sullivan b...@serpentine.com wrote: On Mon, Aug 8, 2011 at 9:24 AM, Chris Yuen kizzx2+hask...@gmail.comwrote: For reference I have asked the same question on StackOverflow. One person suggested that the reason might be that Int64 on Windows is broken (

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-07 Thread Max Bolingbroke
On 7 August 2011 06:15, Chris Yuen kizzx2+hask...@gmail.com wrote: I am mainly interested in making the Haskell version perform comparatively to the C# version. Right now it is at least 5x slower so obviously I am missing something obvious) You have a map call which is immediately consumed by

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-07 Thread Daniel Fischer
On Sunday 07 August 2011, 10:52:20, Max Bolingbroke wrote: In short I don't see how to get further without changing the algorithm or doing some hacks like manual unrolling. Maybe someone else has some ideas? Well, the C# implementation uses arrays for lookup while the Haskell version uses

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-07 Thread Chris Yuen
Here is an updated version using Data.Array.Unboxed http://ideone.com/YXuVL And the profile http://hpaste.org/49940 Still taking 5+ minutes... Chris On Sun, Aug 7, 2011 at 5:20 PM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Sunday 07 August 2011, 10:52:20, Max Bolingbroke

Re: [Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-07 Thread Eugene Kirpichov
What about using unsafe array indexing operations? (i.e. array `unsafeAt` index) 2011/8/7 Chris Yuen kizzx2+hask...@gmail.com: Here is an updated version using Data.Array.Unboxed  http://ideone.com/YXuVL And the profile http://hpaste.org/49940 Still taking 5+ minutes... Chris On Sun, Aug

[Haskell-cafe] Analyzing slow performance of a Haskell program

2011-08-06 Thread Chris Yuen
Hello Cafe, I was trying to solve ITA Software's Word Nubmers puzzle ( http://www.itasoftware.com/careers/puzzle_archive.html) using a brute force approach. Here's a my version of a quick recap of the problem: A wordNumber is defined as wordNumber 1 = one wordNumber 2 = onetwo wordNumber 3