From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 04078BC0A for ; Thu, 7 Jun 2007 17:52:07 +0200 (CEST) Received: from smtp.janestcapital.com (www.janestcapital.com [66.155.124.107]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l57Fq5sT014975 for ; Thu, 7 Jun 2007 17:52:06 +0200 Received: from [172.25.131.105] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id A9B00208; Thu, 07 Jun 2007 11:52:16 -0400 Message-ID: <466829A3.2090508@gnu.org> Date: Thu, 07 Jun 2007 11:52:03 -0400 From: Sam Steingold User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: compiling large file hogs RAM and takes a long time. References: <4666E11F.6000308@podval.org> In-Reply-To: <4666E11F.6000308@podval.org> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 466829A6.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hash:01 parser:01 ocaml:01 variants:01 ocaml:01 conceptually:01 variants:01 foo:01 foo:01 ocamlopt:01 3050:98 polymorphic:01 polymorphic:01 wrote:01 wrote:01 -----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-----