ghc: out of memory error while compiling huge "let"

I have a machine-generated source-code file that brings my computer to its knees with ghc-6.6. After an hour or so of rummaging around, ghc dies with: "ghc-6.6: out of memory (requested 1048576 bytes)". The linux machine has 1gb RAM and 2gb swap, and I don't have access to a better one. The file is of the form ------------------------------------------- module foo (a,b) where (a,b) = let ...10,300 bindings... ; in ([a1,a2,a3...a300],[b1,b2,b3...b10000]) -------------------------------------------- Is there some simple syntactic refactoring I can do to make this work? E.g. busting the local bindings out of the "let" and into to the global level? The bindings are intertwined, but I could (with some effort) reorder them so that b5000 would only reference b5001...b10000 and never b1...b4999.

On 1/12/07, David Morse
Is there some simple syntactic refactoring I can do to make this work? E.g. busting the local bindings out of the "let" and into to the global level?
The bindings are intertwined, but I could (with some effort) reorder them so that b5000 would only reference b5001...b10000 and never b1...b4999.
Somehow I doubt that the answer is going to be that simple, but for starters, what's your ghc command line? (In particular, are you compiling with -O or not? If ghc is eating that much memory than I'd assume you are, but one should never assume.) Cheers, Kirsten -- Kirsten Chevalier* chevalier@alum.wellesley.edu *Often in error, never in doubt "by God I *KNOW* what this network is for, and you can't have it."--Russ Allbery

Hi David,
I found that GHC is O(n^2) in terms of the number of lines in a do
block, so by splitting up a huge 1000 line do block in to 10 x 100
line do blocks, I was able to get a massive compile time boost.
Perhaps you might have similar luck with let's.
If you do, report a bug!
Thanks
Neil
On 1/12/07, David Morse
I have a machine-generated source-code file that brings my computer to its knees with ghc-6.6. After an hour or so of rummaging around, ghc dies with: "ghc-6.6: out of memory (requested 1048576 bytes)". The linux machine has 1gb RAM and 2gb swap, and I don't have access to a better one.
The file is of the form ------------------------------------------- module foo (a,b) where
(a,b) = let ...10,300 bindings... ; in ([a1,a2,a3...a300],[b1,b2,b3...b10000]) --------------------------------------------
Is there some simple syntactic refactoring I can do to make this work? E.g. busting the local bindings out of the "let" and into to the global level?
The bindings are intertwined, but I could (with some effort) reorder them so that b5000 would only reference b5001...b10000 and never b1...b4999. _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Neil Mitchell wrote:
I found that GHC is O(n^2) in terms of the number of lines in a do block, so by splitting up a huge 1000 line do block in to 10 x 100 line do blocks, I was able to get a massive compile time boost. Perhaps you might have similar luck with let's.
Didn't we fix the do-block blowup? Certainly do submit a bug report if you find GHC going O(n^2) or worse on any particular construct, usually we can find the culprit and fix it. Cheers, Simon

On Fri, Jan 12, 2007 at 12:32:47PM -0500, David Morse wrote:
I have a machine-generated source-code file that brings my computer to its knees with ghc-6.6. After an hour or so of rummaging around, ghc dies with: "ghc-6.6: out of memory (requested 1048576 bytes)".
I've made a bug report at http://hackage.haskell.org/trac/ghc/ticket/1136 which is hopefully similar enough that it will cover your case too. If it's not confidential, you might like to add your example to the report too so that we can check it is really fixed when look into it. Thanks Ian
participants (5)
-
David Morse
-
Ian Lynagh
-
Kirsten Chevalier
-
Neil Mitchell
-
Simon Marlow