caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Chambart <pierre.chambart@laposte.net>
To: Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: Matti Jokinen <moj@tanssi.net>,
	Raphael Proust <raphlalou@gmail.com>, SerP <serp256@gmail.com>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Very slow compilation
Date: Wed, 14 Mar 2012 09:52:47 +0100	[thread overview]
Message-ID: <4F605C5F.3020802@laposte.net> (raw)
In-Reply-To: <f86bae946250d577ed05410c3845d1e4.squirrel@gps.dynxs.de>

Le 13/03/2012 23:46, Gerd Stolpmann a écrit :
>> ocamldebug /usr/bin/ocamlduceopt -c big_ocamlduce_module.ml
>> run
>> ... wait about two minutes and press control-C
>>
>> You will probably find the compiler executing a function from modules
>> such as Interf, Coloring or Spill, or a lower level function called
>> from these modules.
> This was also my observation.
>
>> I have never observed anything similar in OCaml, but ocamlduceopt
>> appears to use unmodified ocamlopt code generation modules.  I wonder
>> what is the critical difference between OCamlDuce code and typical
>> OCaml code at this level.
> I guess the only difference is the length of the code passed at once to
> the backend, since you can generate code showing this problem for standard
> ocamlopt, as in my Hydro case.
>
I had a similar case where (handwritten) code took a long time to do
register allocation.
After looking more closely it seems that all declarations in modules
have effects that
interfere: in the coloring graph, every vertex corresponding to the
effect of affecting
the function to the field of the module has an edge to every other such
vertex. Since
the graph is represented by a set of edges, it is something like a
n².log(n) complexity
for creating the graph.

Notice that it doesn't occur for values declared at toplevel.

A simple trick to circumvent that is to split the module in submodules
and include
them later.

module M = struct
    let a1 x = x
    ...
    let an x = x
    let b1 x = x
    ...
    let bn x = x
    ...
end

is replaced by

module M = struct
    module A = struct
    let a1 x = x
    ...
    let an x = x
    end
    module B = struct
    let b1 x = x
    ...
    let bn x = x
    end
    ...

    include A
    include B
    ...
end
-- 
Pierre

  parent reply	other threads:[~2012-03-14  8:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-11  8:11 SerP
2012-03-11  8:39 ` Gabriel Scherer
2012-03-11  9:04   ` Adrien
2012-03-11  9:21   ` Raphael Proust
2012-03-13 22:02     ` Matti Jokinen
2012-03-13 22:46       ` Gerd Stolpmann
2012-03-14  5:33         ` Gabriel Scherer
2012-03-14  8:52         ` Pierre Chambart [this message]
2012-03-13 16:58 ` Richard W.M. Jones
2012-03-14 14:45 tools

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=4F605C5F.3020802@laposte.net \
    --to=pierre.chambart@laposte.net \
    --cc=caml-list@inria.fr \
    --cc=info@gerd-stolpmann.de \
    --cc=moj@tanssi.net \
    --cc=raphlalou@gmail.com \
    --cc=serp256@gmail.com \
    /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).