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: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Does the gc avoid collecting arrays of ints
On Monday 23 July 2007 18:35:40 Till Varoquaux wrote:
> Looking at ocaml's source code I see that the values representing
> arrays have a tag representing the type of their content (I'm guessing
> boxed/unboxed). Does this mean that a bidimensional array containing
> ints will only be explored in one direction during garbage collection?
> If so, how do the compare to Bigarray's (I'm guessing they still are
> slower).

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

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 found this performance characteristic whilst optimizing Smoke's worst case 
performance, which is very important for such soft-real-time applications. I 
had "optimized" by memoizing stuff and things in a hash table, which turned 
out to slow the GC down enormously whenever it stumbled upon the hash table.

Incidentally, I get the distinct impression that Chistophe's question isn't 
going to get answered until the ICFP is done and dusted and everyone has 
recouperated. ;-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e