English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Gripes with array
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-09-10 (13:46)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Gripes with array
On Sep 9, 2004, at 18:58, Jon Harrop wrote:

>>> Also, can Array.init be made to fill the elements only once?
>> No, that's impossible without breaking the GC invariants.
> Could it not even be done by dragging Array.init inside the compiler, 
> giving
> it the same status as Array.make?

Not without implementing such horrors as Christophe described.  I don't 
like the idea of introducing lots of bugs while slowing down the whole 
even for programs that don't use arrays.  An intermediate solution would
be to make a "Array.unsafe_make" primitive, which would use memset 
of initialising the array properly.  If you enter this as a feature wish
in the BTS, I'll look into it.

> Measuring memset from C gives me 0.0311secs. So element-setting must 
> be at
> least 10% of Array.init. Also, the array_init function is surprisingly 
> fast,
> presumably due to "f" not being inlined into Array.init but being 
> inlined
> into array_init.

That would confirm my intuition that the calls to f dominates the
initialisation time.

-- Damien

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners