caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jonathandeanharrop@googlemail.com>
To: caml-list@yquem.inria.fr
Cc: Raj Bandyopadhyay <rajb@rice.edu>
Subject: Re: [Caml-list] Native code compile time question
Date: Fri, 5 Sep 2008 23:44:13 +0100	[thread overview]
Message-ID: <200809052344.13606.jon@ffconsultancy.com> (raw)
In-Reply-To: <48C15DA2.6060800@rice.edu>

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


  parent reply	other threads:[~2008-09-05 21:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-05 16:26 Raj Bandyopadhyay
2008-09-05 21:32 ` [Caml-list] " Basile STARYNKEVITCH
2008-09-05 22:46   ` Jon Harrop
2008-09-05 22:44 ` Jon Harrop [this message]
2008-09-06 10:01 ` Richard Jones
2008-09-06 10:38 ` Christophe TROESTLER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200809052344.13606.jon@ffconsultancy.com \
    --to=jonathandeanharrop@googlemail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=rajb@rice.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).