From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8CC06BC88 for ; Thu, 10 Feb 2005 20:20:22 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1AJKMw5023739 for ; Thu, 10 Feb 2005 20:20:22 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA01206 for ; Thu, 10 Feb 2005 20:20:21 +0100 (MET) Received: from mailout03.sul.t-online.com (mailout03.sul.t-online.com [194.25.134.81]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1AJKL4S023735 for ; Thu, 10 Feb 2005 20:20:21 +0100 Received: from fwd07.aul.t-online.de by mailout03.sul.t-online.com with smtp id 1CzJrR-0002Sk-00; Thu, 10 Feb 2005 20:20:21 +0100 Received: from [217.82.239.182] (STm71kZUwewaxZP58oqB6ay+wP-AwKN6UUtkxyIwAQ9aqMC5BqWjY7@[217.82.239.182]) by fwd07.sul.t-online.com with esmtp id 1CzJr8-1ST5c00; Thu, 10 Feb 2005 20:20:02 +0100 Message-ID: <420BB3E3.1060005@t-online.de> Date: Thu, 10 Feb 2005 20:20:03 +0100 From: Christian Szegedy User-Agent: Mozilla Thunderbird 1.0 (X11/20050131) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Memory allocation nano-benchmark. References: <420B7A7E.90504@or.uni-bonn.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ID: STm71kZUwewaxZP58oqB6ay+wP-AwKN6UUtkxyIwAQ9aqMC5BqWjY7 X-TOI-MSGID: 6600c8af-434a-4150-b000-7b43d208c6e8 X-Miltered: at nez-perce with ID 420BB3F6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 420BB3F5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 prevost:01 prevost:01 wrote:01 allocates:01 o'caml:01 chunks:01 chunks:01 malloc:01 pointer:01 malloc:01 arrays:01 ocaml:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Marwan Burelle wrote: >On Thu, 10 Feb 2005 09:59:53 -0500, John Prevost 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.