Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Mikhail Glushenkov
Hi all, This came up on StackOverflow [1]. When compiled with GHC (7.4.2 7.6.2), this simple program: main = print $ ack 4 1 where ack :: Int - Int - Int ack 0 n = n+1 ack m 0 = ack (m-1) 1 ack m n = ack (m-1) (ack m (n-1)) consumes all available memory on my machine

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Christopher Done
JHC compiles to C and last time I tried this it looked very much like the original C version: http://www.reddit.com/r/haskell/comments/1bcru7/damn_lies_and_haskell_performance/c9689a3 This is the same thing. Compile with --tdir=/tmp/ajhc and then cat /tmp/ajhc/main_code.c. Output should be like

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Mikhail Glushenkov
Hi, On Sat, Apr 20, 2013 at 12:08 PM, Christopher Done chrisd...@gmail.com wrote: JHC compiles to C and last time I tried this it looked very much like the original C version: http://www.reddit.com/r/haskell/comments/1bcru7/damn_lies_and_haskell_performance/c9689a3 This is the same thing.

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Mikhail Glushenkov
On Sat, Apr 20, 2013 at 12:23 PM, Mikhail Glushenkov the.dead.shall.r...@gmail.com wrote: Surely it must be possible to make the GHC version at least 2x as slow as Ocaml/GHC? s|Ocaml/GHC|Ocaml/JHC| -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Dan Doel
There's something strange going on in this example. For instance, setting (-M) heap limits as low as 40K seems to have no effect, even though the program easily uses more than 8G. Except, interrupting the program in such a case does seem to give a message about heap limits being exceeded (it won't

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Mikhail Glushenkov
Hi, On 20 April 2013 14:20, Dan Doel dan.d...@gmail.com wrote: There's something strange going on in this example. For instance, setting (-M) heap limits as low as 40K seems to have no effect, even though the program easily uses more than 8G. Apparently the only things it allocates is stack

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Edward Z. Yang
I don't seem to get the leak on latest GHC head. Running the program in GC debug mode in 7.6.2 is quite telling; the program is allocating *a lot* of megablocks. We probably fixed it though? Edward Excerpts from Mikhail Glushenkov's message of Sat Apr 20 01:55:10 -0700 2013: Hi all, This

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Joachim Breitner
Hi, Am Samstag, den 20.04.2013, 13:03 -0700 schrieb Edward Z. Yang: I don't seem to get the leak on latest GHC head. Running the program in GC debug mode in 7.6.2 is quite telling; the program is allocating *a lot* of megablocks. We probably fixed it though? it’s confirmed that it is fixed

Re: Why is GHC so much worse than JHC when computing the Ackermann function?

2013-04-20 Thread Thomas Schilling
Sounds similar to the bug we had in 6.12.1. It was a simple accounting bug, i.e., the GC was not invoked, because it didn't know that the memory was allocated. On 20 April 2013 22:03, Edward Z. Yang ezy...@mit.edu wrote: I don't seem to get the leak on latest GHC head. Running the program in