Version française
Home     About     Download     Resources     Contact us    
Browse thread
compiling large file hogs RAM and takes a long time.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sam Steingold <sds@g...>
Subject: Re: compiling large file hogs RAM and takes a long time.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sam Steingold wrote:
> I wrote a parser generator for a tick data file.
> The generated OCaml file is ~1Mb and contains ~120 variant type
> definitions (each with 2 to ~100 variants) plus one polymorphic variant
> type.
> When I tried to compile it (3.09.3), it took almost 10 minutes and
> consumed ~500MB RAM (Firefox and Thunderbird were killed by the kernel
> to make space for ocaml).
> I run Linux 2.6.18.8 on a dual CPU Pentium D 2.80GHz with 1GB of RAM.
> (in 32-bit mode)
> 
> So, is this something to be expected? 10 min / 500MB seems like a little
> bit excessive to me, given that the file is really very simple conceptually.

update: the main problem is a polymorphic variant type with 3050
variants and a function that returns its instances.
chunking the type, i.e., replacing
type foo=[|`A|`B|`C|`D]
with
type foo_1=[|`A|`B]
type foo_2=[|`C|`D]
type foo=[|foo_1|foo_2]
(but with ~55 variants in ~55 types) did not help.
Removing the type definition did solve the RAM problem - according to
top(1), ocamlopt.opt was taking ~80MB, and it compiled the file in about
10 minutes.

Any chance there is some quadratic code in polymorphic variant type
processing?!

Sam.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGaCmjPp1Qsf2qnMcRAn52AJ4vKgALmumuKvzgo3aiG4LaavmKJACeKfWn
glb7ZDcjbMt/lIWYWMmPF5M=
=xr5y
-----END PGP SIGNATURE-----