caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Bardou <romain.bardou@inria.fr>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Accelerating compilation
Date: Fri, 06 Sep 2013 17:19:32 +0200	[thread overview]
Message-ID: <5229F284.5050806@inria.fr> (raw)
In-Reply-To: <CAP_800p=kanKKtEj6jvpYzeXm-hnpakAyCOO3s-sCtETE_f=mg@mail.gmail.com>

Le 06/09/2013 16:55, Markus Mottl a écrit :
> On Fri, Sep 6, 2013 at 9:56 AM, Romain Bardou <romain.bardou@inria.fr> wrote:
>> 1) Separate typing and code generation, in ocamlc and in ocamlopt
>>
>> For instance, provide an option -typing-only which would mean "only
>> produce the .cmi but do not produce the .cmo or the .cmx". The compiler
>> would only need the .cmi of the dependencies, not their .cmo or .cmx.
>> This would make it possible to have a Makefile target, or an Ocamlbuild
>> option, to just type.
> 
> This seems like an interesting suggestion.  Code generation,
> especially for native code, can be quite expensive.  I do use byte
> code compilation during development for that reason, which is somewhat
> faster.

I considered doing that, but my project has some stubs which do not work
in bytecode for some reason (probably fixable). Also, it would mean that
I would have to compile both versions, as the program is too slow to be
used in bytecode, so the bytecode would only be used for quick
type-checking.

> Note, however, that there is one problem with the approach as
> suggested: if you have both an .mli and an .ml file, the build system
> would have to know when to "type" the latter.  In the suggested
> approach there would be no trace of this action, because the .cmi
> would come from the .mli file.  We would need to generate a separate
> dummy file in that case to visibly record the fact that the .ml file
> unifies with the .cmi file.  Or (see below) write out the typed
> abstract syntax tree of the .ml file, which would, of course, also
> have to unify with the .cmi file.

Indeed the build system would need to be tweaked. Another approach would
be to consider that .cmi files depend on .ml files as well, maybe only
if an option -just-type is passed. I'm not sure of the implications.

>> Also, provide an option -do-not-retype which would mean "if the .cmi
>> exists, load it instead of type-checking again". This would allow the
>> build process to first type-check (using -typing-only) and then generate
>> the code without type-checking again (using -do-not-retype). Of course
>> the build system should be very careful to ensure the .cmi is
>> up-to-date. This option could also help when compiling both in bytecode
>> and in native code. This option is not necessary to just find errors
>> quickly, though.
> 
> The .cmi file does not contain enough information, because it only
> contains the signature.  You need the typed AST for proper code
> generation, which might be quite big.  I haven't looked into this, but
> I wouldn't be surprised if the size of that thing could be so large
> that you might prefer type checking again over writing to + reloading
> it from a file.

Ah right I was thinking it contained the whole typed tree for some
reason, which is indeed not the case.

>> 2) Be able to disable Ocamlbuild's digest mechanism and use dates and
>> file sizes instead
>>
>> If I am not mistaken, this is one of the main reasons why Ocamlbuild is
>> slower that make. It does help to prevent useless recompilation, but
>> what good does it make to prevent a useless recompilation once in a
>> while if it is at the cost of losing a lot of time in all other cases?
>> I'm sure it is project-dependent though so it should only be an option,
>> say, -do-not-hash, or -comparison-mode dateandsize.
> 
> The problem here is that not all Unix-filesystems support sub-second
> resolution in timestamps.  So if you build a file and change a
> character in it within one second, the change may go unnoticed, i.e.
> required recompilation doesn't happen.  That's why hashing provides
> much stronger guarantees.  But I think this is not a big problem in
> practice so I'd support such a flag in ocamlbuild.
> 
>> 3) Parallel compilation in Ocamlbuild
>>
>> Of course it would help but it is not easy to implement so I'm just
>> putting it there to be exhaustive.
> 
> I'm not sure what you are referring to, OCamlBuild does already
> support parallel builds.

Does it? I actually thought the -j option was ignored.

I just did a quick test and I gain about 5 seconds with -j on a 1min15
build (I had cleaned, recompiled and recleaned before so that caching by
the file system would not impact the result too much), so it does seem
to be a *little* faster :)

Cheers,

-- 
Romain Bardou

  reply	other threads:[~2013-09-06 15:19 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-06 13:56 Romain Bardou
2013-09-06 14:55 ` Markus Mottl
2013-09-06 15:19   ` Romain Bardou [this message]
2013-09-06 15:27     ` Gabriel Scherer
2013-09-06 15:33       ` Alain Frisch
2013-09-06 20:51     ` Fabrice Le Fessant
2013-09-09  7:44       ` Romain Bardou
2013-09-11 13:00       ` Francois Berenger
2013-09-11 13:46         ` Wojciech Meyer
2013-09-12  1:23           ` Francois Berenger
2013-09-12 15:15             ` Jacques Le Normand
2013-09-30  8:06       ` [Caml-list] from oasis to obuild (original subject was Re: Accelerating compilation) Francois Berenger
2013-09-30  8:18         ` Török Edwin
2013-09-30  9:00         ` Fabrice Le Fessant
2013-09-30  9:13           ` Anil Madhavapeddy
2013-09-30 11:13             ` Alain Frisch
2013-09-30 11:19               ` Anil Madhavapeddy
2013-09-30 11:27                 ` Alain Frisch
2013-09-30 11:36                   ` Anil Madhavapeddy
2013-09-30  9:18           ` Francois Berenger
2013-09-30 14:11         ` Sylvain Le Gall
2013-10-01  0:57           ` Francois Berenger
2013-10-01 12:25             ` Sylvain Le Gall
2013-09-07 11:37     ` [Caml-list] Accelerating compilation Matej Kosik
2013-09-08  6:37     ` Francois Berenger
2013-09-06 15:18 ` Gabriel Scherer
2013-09-06 15:28   ` Romain Bardou
2013-09-06 16:04   ` Markus Mottl
2013-09-06 16:30 ` Xavier Leroy
2013-09-07 19:13   ` Wojciech Meyer
2013-09-07 21:42     ` Jacques-Pascal Deplaix
2013-09-08  1:59       ` Markus Mottl
2013-09-09  7:59   ` Romain Bardou
2013-09-09  8:25   ` Alain Frisch
2013-09-09  8:35     ` Francois Berenger
2013-09-09 10:13     ` Anil Madhavapeddy
2013-09-09 17:08     ` Adrien Nader
2013-09-09 17:17       ` Gabriel Kerneis
2013-09-10  2:01     ` oleg
2013-09-10 10:21       ` Gerd Stolpmann
2013-09-10 16:15       ` Adrien Nader
2013-09-10 16:46       ` Xavier Leroy
2013-09-10 16:53         ` Adrien Nader
2013-09-10 17:43           ` ygrek
2013-09-06 18:45 ` Martin Jambon
2013-09-09  8:15   ` Romain Bardou
2013-09-09  8:36     ` Francois Berenger
2013-09-09  8:41       ` Thomas Refis
2013-09-09 17:32     ` Aleksey Nogin

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=5229F284.5050806@inria.fr \
    --to=romain.bardou@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=markus.mottl@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).