From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=2.0 required=5.0 tests=AWL,NO_DNS_FOR_FROM autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 514EFBB84 for ; Tue, 12 Aug 2008 21:05:06 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AowCANh7oUiBYYw6jWdsb2JhbACRcQEBAQEJBQgYBaVeA4FP X-IronPort-AV: E=Sophos;i="4.32,197,1217800800"; d="asc'?scan'208";a="28171121" Received: from services107.math.uwaterloo.ca ([129.97.140.58]) by mail4-smtp-sop.national.inria.fr with ESMTP; 12 Aug 2008 21:05:05 +0200 Received: from saturn (CPE00195b945ab9-CM001a6682b9fa.cpe.net.cable.rogers.com [99.249.252.9]) (authenticated bits=0) by services107.math.uwaterloo.ca (8.13.8/8.13.8) with ESMTP id m7CJ4wq0005788 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 12 Aug 2008 15:05:03 -0400 (EDT) Received: from matt by saturn with local (Exim 4.69) (envelope-from ) id 1KSzAo-0001UF-91 for caml-list@yquem.inria.fr; Tue, 12 Aug 2008 15:04:52 -0400 Date: Tue, 12 Aug 2008 15:04:49 -0400 From: Matthew William Cox To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Tuple allocation overhead Message-ID: <20080812190448.GA4582@saturn.mattcox.ca> References: <48A1B59A.3080203@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline In-Reply-To: <48A1B59A.3080203@gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-3.0 (services107.math.uwaterloo.ca [129.97.140.58]); Tue, 12 Aug 2008 15:05:03 -0400 (EDT) X-Miltered: at mailchk-w01 with ID 48A1DEDA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Virus-Scanned: ClamAV version 0.93.1, clamav-milter version 0.93.1 on localhost X-Virus-Status: Clean X-UUID: a371a3bb-f0c8-4b95-9845-0d420510bd08 X-Spam: no; 0.00; malloc:01 malloc:01 ocaml:01 runtime:01 iirc:01 ocaml:01 pointer:01 pointer:01 allocates:01 garbage:01 wrote:01 heap:01 caml-list:01 tuple:02 tuple:02 X-Attachments: type="application/pgp-signature" name="signature.asc" --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 12, 2008 at 11:08:58AM -0500, Raj Bandyopadhyay wrote: > I was wondering if someone has a good explanation for this. I assume it = =20 > has to do with some overhead of malloc, but I'm not sure. I doubt it's anything to do with malloc. The ocaml runtime does its own memory management, which includes allocation of caml objects and garbage collection. Storage is obtained from the system en masse. > Why is it that a tuple of size 2 is more expensive to allocate than > size 3-5 in this case? Are there other factors involved that I am not > considering? I can't explain this. Have you tried both 32 and 64 bit archs, or at least CPUs with different cache characteristics? There might be architecture dependent parameters in the GC. IIRC, allocation in ocaml is increment and test of a pointer. If the pointer extends beyond the heap, it's necessary to perform a GC. Your code also allocates a list cell at each step. Maybe the combination of list cell and tuple cell is triggering cache misses differently? Matt --xHFwDpU9dbj6ez1V Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkih3tAACgkQLzoc++7UJR9SoQCgpBnvl53WX8v37HEAkcqhqA3F YEsAoJjJhIgZSRqotgksUEcev5pE376s =hb1E -----END PGP SIGNATURE----- --xHFwDpU9dbj6ez1V--