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
[Caml-list] Efficiency of 'a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-05-04 (12:56)
From: Eray Ozkural <exa@k...>
Subject: Re: [Caml-list] Efficiency of 'a list
On Sunday 04 May 2003 13:56, Neel Krishnaswami wrote:
> > Don't trust microbenchmarks too far over what your knowledge of how
> > things should work tell you. Iterating over arrays is certainly
> > going to be much more cache-and TLB-friendly.
> This is not be as true you think. Ocaml's garbage collector is a
> compacting, copying GC, so it's very likely that lists will end up in
> in continuous blocks of memory. This will end up being nearly as
> cache-friendly as an array is.
> The big exception is with arrays of floats -- Ocaml unboxes arrays of
> floats, but doesn't unbox lists of them.

Now, we're getting some performance talk :)

To be precise, comparing an int list and int array we'll see that list 
occupies twice the same memory and therefore will generate more cache misses. 
But as the size of 'a in 'a list grows the difference will be negligible. 
However, if one modifies the elements of an array, in FORTRAN style, won't 
really be storing huge records inside elements of the array. He will likely 
split things up in parallel arrays where necessary, and if there are records 
they will be stored in a private heap and pointers will be stored in the 
array, etc.


Eray Ozkural (exa) <>
Comp. Sci. Dept., Bilkent University, Ankara  KDE Project:
www:  Malfunction:
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: