Browse thread
Memory allocation nano-benchmark.
-
Christian Szegedy
- Frédéric_Gava
- Jon Harrop
-
John Prevost
-
Marwan Burelle
- Christian Szegedy
- skaller
-
Marwan Burelle
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-02-10 (19:20) |
From: | Christian Szegedy <szegedy@t...> |
Subject: | Re: [Caml-list] Memory allocation nano-benchmark. |
Marwan Burelle wrote: >On Thu, 10 Feb 2005 09:59:53 -0500, John Prevost <j.prevost@gmail.com> wrote: > > >>In a program that allocates one very large chunk of memory, I suspect >>you will find that both C and O'Caml do a lot better when... you >>allocated as one very large chunk of memory (or, if need be, a *tiny* >>number of large chunks) instead of as many small chunks of memory. >> >> > >It also depends on malloc, on Linux it sometimes works >"optimisticaly", that is, it won't realy allocate memory unless you >use it (leading to some strange out of memory error, since it can >return a non-Null pointer even if memory isn't available.) So, a C >program with a lot of malloc and no usage of the memory allocated >could be faster than it realy is ... > >My 2cc. > Actually, I have *filled* the arrays, as it may be clear from the code. This example was extracted from a program which massively shuffles around the content of this 3-dimensional grid. (Both work fine and yield identical output.) To my astonishment, the OCaml was a bit faster than C when working on the grid, but the speed of allocation was nowhere near to that of the C version. This was a surprise to me, since I thought that OCaml is quite competitive in this regard.