Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Gripes with array
On Fri, 2004-09-10 at 23:45, Damien Doligez wrote:

>  An intermediate solution would
> be to make a "Array.unsafe_make" primitive, which would use memset 
> instead of initialising the array properly.  

Yeah but that doesn't solve the problem of filling
the array initially with some 'non-binary-zero' value.
You'd still need two passes: the memset and the
proper fill (hence paging all the memory in twice).

AFAICS tracking how much of an array is initialised
with an index the GC can use costs a single
comparison when you're not initialising arrays.
EG: the GC has a list of blocks undergoing
initialisation, determining the list is empty
should be a single machine instruction.

If you're initialising an array without any
recursion, that's two comparisons.

So the only time there would be a serious impact
on the GC would be if you're initialising many
big arrays all at once (EG if you're making a matrix
as an array of arrays), and that cost would be
small compared to scanning twice.

I can't predict the performance of the one
extra comparison needed when no arrays are
being initialised because it probably depends
on the processor cache design -- how much
can one machine instruction + one memory
reference cost?

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
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