Compiling large source files

Hi all, I'm having trouble compiling very large source files, the compiler eats 2GB and then dies. Is there a way around it? Günther

Can you define "very large" and "compiler"? I know an old version of
GHC (6.6?) would eat lots of memory when there were absurd numbers of
let statements.
Thomas
2009/8/3 Günther Schmidt
Hi all,
I'm having trouble compiling very large source files, the compiler eats 2GB and then dies. Is there a way around it?
Günther _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Hi Thomas,
yes, a source file with a single literal list with 85k elements.
Günther
Am 03.08.2009, 22:20 Uhr, schrieb Thomas DuBuisson
Can you define "very large" and "compiler"? I know an old version of GHC (6.6?) would eat lots of memory when there were absurd numbers of let statements.
Thomas
2009/8/3 Günther Schmidt
: Hi all,
I'm having trouble compiling very large source files, the compiler eats 2GB and then dies. Is there a way around it?
Günther _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

I suggest not using Haskell for your list. Put the data in a file and read it at runtime, or put it in a static C array and link it in. Cheers, Simon On 03/08/2009 22:09, Günther Schmidt wrote:
Hi Thomas,
yes, a source file with a single literal list with 85k elements.
Günther
Am 03.08.2009, 22:20 Uhr, schrieb Thomas DuBuisson
: Can you define "very large" and "compiler"? I know an old version of GHC (6.6?) would eat lots of memory when there were absurd numbers of let statements.
Thomas
2009/8/3 Günther Schmidt
: Hi all,
I'm having trouble compiling very large source files, the compiler eats 2GB and then dies. Is there a way around it?
Günther _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On Tue, Aug 04, 2009 at 09:12:37AM +0100, Simon Marlow wrote:
I suggest not using Haskell for your list. Put the data in a file and read it at runtime, or put it in a static C array and link it in.
On 03/08/2009 22:09, G?nther Schmidt wrote:
Hi Thomas, yes, a source file with a single literal list with 85k elements.
People, when a program only defines and returns a String constant of n literals, how much memory needs ghc-6.10.4 to compile it ? O(n), or may be O(n^2), or ... Regards, ----------------- Serge Mechveliani mechvel@botik.ru

On 04/08/2009 13:30, Serge D. Mechveliani wrote:
On Tue, Aug 04, 2009 at 09:12:37AM +0100, Simon Marlow wrote:
I suggest not using Haskell for your list. Put the data in a file and read it at runtime, or put it in a static C array and link it in.
On 03/08/2009 22:09, G?nther Schmidt wrote:
Hi Thomas, yes, a source file with a single literal list with 85k elements.
People, when a program only defines and returns a String constant of n literals, how much memory needs ghc-6.10.4 to compile it ? O(n), or may be O(n^2), or ...
Certainly not O(n^2), we would class that as a bug. I can imagine it might be worse than linear however, if not in memory at least in time. Here's some very rough reasoning: GHC has to maintain various kinds of mappings to do its work. A mapping from variables is O(logn) to look up in, and we have to do at least O(n) lookups since there are O(n) variables, so compilation will be O(nlogn). We should remember that typechecking is worst-case exponential in space and time, though that is rarely an issue in practice. String constants are a special case because they are stored internally as flat arrays of bytes, so you'll probably get closer to O(n) with a much better constant factor. Cheers, Simon

It should be pretty much linear (modulo a log(n) factor, but then log(n) is practically constant (=64 or so).). But people often report that GHC is slow (perhaps non-linearly so) when compiling vast blobs of literal data. Because there is a reasonable workaround (just parse the data), which actually makes your program more flexible (since you can change the data without recompiling), we have serially failed to look hard at this problem. I wish someone would nail it, though. Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell- | users-bounces@haskell.org] On Behalf Of Serge D. Mechveliani | Sent: 04 August 2009 13:31 | To: Simon Marlow | Cc: glasgow-haskell-users@haskell.org | Subject: Re: Compiling large source files | | On Tue, Aug 04, 2009 at 09:12:37AM +0100, Simon Marlow wrote: | > I suggest not using Haskell for your list. Put the data in a file and | > read it at runtime, or put it in a static C array and link it in. | > | > On 03/08/2009 22:09, G?nther Schmidt wrote: | > >Hi Thomas, | > >yes, a source file with a single literal list with 85k elements. | | | People, | when a program only defines and returns a String constant of n | literals, how much memory needs ghc-6.10.4 to compile it ? | O(n), or may be O(n^2), or ... | | Regards, | | ----------------- | Serge Mechveliani | mechvel@botik.ru | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Gunther
Could you make a Trac bug report for this, and attach your source file?
It'd help if you could first check that things are still bad with GHC 6.10.4.
Another useful thing would be to provide data on whether the behaviour is non-linear. Eg try with 1k, 2k, 4k, 8k, etc elements in your list and see how it behaves.
Providing reproducible and well-characterised bug reports greatly increases the likelihood that we'll fix it!
Thanks
Simon
| -----Original Message-----
| From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users-
| bounces@haskell.org] On Behalf Of Günther Schmidt
| Sent: 03 August 2009 22:09
| To: Thomas DuBuisson
| Cc: glasgow-haskell-users@haskell.org
| Subject: Re: Compiling large source files
|
| Hi Thomas,
|
| yes, a source file with a single literal list with 85k elements.
|
|
| Günther
|
|
| Am 03.08.2009, 22:20 Uhr, schrieb Thomas DuBuisson
|

Gunther should first check if he thinks this is the same issue as http://hackage.haskell.org/trac/ghc/ticket/2002 (looks similar to me) If it is, he could just add comments there. Simon Peyton-Jones wrote:
Gunther
Could you make a Trac bug report for this, and attach your source file?
It'd help if you could first check that things are still bad with GHC 6.10.4.
Another useful thing would be to provide data on whether the behaviour is non-linear. Eg try with 1k, 2k, 4k, 8k, etc elements in your list and see how it behaves.
Providing reproducible and well-characterised bug reports greatly increases the likelihood that we'll fix it!
Thanks
Simon
| -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Günther Schmidt | Sent: 03 August 2009 22:09 | To: Thomas DuBuisson | Cc: glasgow-haskell-users@haskell.org | Subject: Re: Compiling large source files | | Hi Thomas, | | yes, a source file with a single literal list with 85k elements. | | | Günther | | | Am 03.08.2009, 22:20 Uhr, schrieb Thomas DuBuisson |
: | | > Can you define "very large" and "compiler"? I know an old version of | > GHC (6.6?) would eat lots of memory when there were absurd numbers of | > let statements. | > | > Thomas | > | > 2009/8/3 Günther Schmidt : | >> Hi all, | >> | >> I'm having trouble compiling very large source files, the compiler eats | >> 2GB | >> and then dies. Is there a way around it? | >> | >> Günther | >> _______________________________________________ | >> Glasgow-haskell-users mailing list | >> Glasgow-haskell-users@haskell.org | >> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users | >> | | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (6)
-
Günther Schmidt
-
Jules Bean
-
Serge D. Mechveliani
-
Simon Marlow
-
Simon Peyton-Jones
-
Thomas DuBuisson