Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Concurrent ocamlbuild
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Concurrent ocamlbuild
Excerpts from jon's message of Mon Nov 05 11:11:42 +0100 2007:
> On Sunday 04 November 2007 18:06, Erick wrote:
> > Did you see the -j N option?
> >
> >  > ocamlbuild -h
> >
> > ...
> >   -j <N>                      Allow N jobs at once (0 for unlimited)
> > ...
> I hadn't noticed that, thanks. However, it doesn't seem to work (at least for 
> this project). My old Makefile takes 21s and ocamlbuild with -j anything 
> still takes at least 45s. Moreover, the Makefile isn't as parallel as it 
> could be...

Is it native compilation, byte-code compilation?

The  byte-code  one  offer  more opportunities for parallelism than the native
one  if  we  respect  dependencies  to  allow cross module inlining. Since the
compiler  does not complain about not found ".cmx" you can do more parallelism
in  your  Makefile.  However  that's risky and can leads to worst performances
(less inlining).

Sometimes  using  libraries  (.mllib)  can  give  more  parallelism  than  the
traditional ocamlbuild discovery of sources.

So you can try...

$ cat mylib.mllib
# Put here all modules needed by your main program
# You can gather them by looking at the link command produced by ocamlbuild

$ cat
open Ocamlbuild_plugin;;
open Ocamlbuild_pack;;
dispatch begin function
| After_rules ->
    ocaml_lib "mylib"
| _ -> ()

$ cat _tags
<myprog.{byte,native}>: use_mylib

$ ocamlbuild mylib.cma mylib.cmxa myprog.byte myprog.native

Nicolas Pouillard aka Ertai