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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id A2104BBAF for ; Fri, 5 Sep 2008 23:44:15 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqkBAABFwUhKfU4ZnGdsb2JhbACCMY9IPgEBAQEBCAMKBxGdDYZzAQI X-IronPort-AV: E=Sophos;i="4.32,342,1217800800"; d="scan'208";a="28868274" Received: from ey-out-2122.google.com ([74.125.78.25]) by mail4-smtp-sop.national.inria.fr with ESMTP; 05 Sep 2008 23:44:15 +0200 Received: by ey-out-2122.google.com with SMTP id 6so239702eyi.15 for ; Fri, 05 Sep 2008 14:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:organization:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id:from; bh=G+bqh5T/1zXxymN5nJJlVGtMb4FTngV4NEObLnWneWA=; b=vCJxWZjTyk4SKGje2AVKOe/gLaqRac5BTAviPJc9PfVPUDZJmxy6lRVCs2cA9r28aP Zh7oxLT4v8c22rLQn+MtG1p18s/CzKsBrftTX//IWa0rf5kpn5Xg6uDq4ZwZnjZPxSo8 BdJVPXFA4z3rR8vQ0ZyfXkH5nNTbjtWsLtH38= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=organization:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id:from; b=pTvojysaFhXJeXGh/zWGipQWQIKA5j/S0PI5COhv8opTXjP1GrwRrKt2QAFJghBT5l PbexbVo7tsp+pF5UKMZDicvw3uF21GNSGKgLco1XPu1nV3XfIebTY03p43QF+t6mVASW 1TWeJCZhG1TqdE/NexAwspUsh7eyubNWmwWI0= Received: by 10.210.136.10 with SMTP id j10mr14390835ebd.43.1220651054452; Fri, 05 Sep 2008 14:44:14 -0700 (PDT) Received: from leper.local ( [86.140.183.215]) by mx.google.com with ESMTPS id q9sm1483362gve.5.2008.09.05.14.44.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Sep 2008 14:44:14 -0700 (PDT) Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Native code compile time question Date: Fri, 5 Sep 2008 23:44:13 +0100 User-Agent: KMail/1.9.9 Cc: Raj Bandyopadhyay References: <48C15DA2.6060800@rice.edu> In-Reply-To: <48C15DA2.6060800@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809052344.13606.jon@ffconsultancy.com> From: Jon Harrop X-Spam: no; 0.00; ocaml:01 ocaml:01 compiler:01 compiler:01 bytecode:01 -inline:01 compilation:01 hand-written:01 run-time:01 rebuilding:01 ocamlopt:01 ocamlopt:01 ocamlc:01 -inline:01 pathological:98 On Friday 05 September 2008 17:26:10 Raj Bandyopadhyay wrote: > Hi all > > I am implementing a language by generating OCaml code for input source > and using the OCaml native code compiler. However, I've run into a > strange problem. > > On using my code generator on a large program, I generate a file > containing about 75K lines of OCaml. The native code compiler takes more > than 30 *minutes* to compile this file! The bytecode compiler takes > about 5 secs. > > I ran the native code compiler without any -inline or other > optimizations and its still the same. > > For smaller OCaml files, the compilation time is ok for me. For example, > it takes about 12 seconds to compile a 15K line OCaml file. I have had similar problems and, as you have almost certainly already guessed, the problem is that the OCaml compiler is designed to optimize hand-written code and its optimizer can easily run away when presented with machine generated code. In my case, optimization was irrelevant so I ended up encoding the data in strings and parsing them at run-time. > Any ideas why this might be happening and how I can deal with this? You might consider rebuilding ocamlopt with profiling to see where the time is being spent in the OCaml compiler itself and then make sure your compiler does not generate pathological cases. Without seeing some of your code it is impossible for me to give a more productive answer but I found that some inlining-related optimizations can bog ocamlopt down without affecting ocamlc. So you might also try -inline 0. Can you post the generated code? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e