Version française
Home     About     Download     Resources     Contact us    
Browse thread
Does the gc avoid collecting arrays of ints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] Does the gc avoid collecting arrays of ints
On 7/23/07, Jon Harrop <jon@ffconsultancy.com> wrote:
...
>
> My gut feeling is that an array of arrays would be faster. You might also like
> to abstract away a single array behind the interface of a multidimensional
> array (particularly if you're on 64-bit).
>
Array of arrayrequier you two jump through two indirections (they are
like **int instead of *int), bigarrays are based on a linear backend
whatever there dimension may be. Using single dimension arrays and
building an interface over it sounds like a good solution. I don't
feel like I have the time to benchmark.
For the record: I saw a tremendous performance boost going from two
dimensional arrays of tupple of ints to tupples of bigarrays. By
profilling I can tell I was loosing most of my time collecting local
values. This was probably due to:
_Manipulating a lot of tupples, wich needed to be collected.
_Assigning local variables to rows. This was probably a bad idea to start with..

> However, there are some wierdnesses here. The GC treats the stack and arrays
> of pointers atomically, traversing all elements in one go. So having a single
> large array of boxed values (like an array of arrays or an array of lists in
> a Hashtbl) can cause significant stalls in the incremental GC.
I thought OCaml did not have an incremental GC, and that minor and
major collections were both atomic.
Till
-- 
http://till-varoquaux.blogspot.com/