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 53A55BC75 for ; Wed, 16 Feb 2005 10:52:50 +0100 (CET) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1G9qnrV024829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 16 Feb 2005 10:52:50 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1D1LrS-00045f-PG for caml-list@yquem.inria.fr; Wed, 16 Feb 2005 09:52:46 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Memory allocation nano-benchmark. Date: Wed, 16 Feb 2005 09:54:13 +0000 User-Agent: KMail/1.7.1 References: <420B7A7E.90504@or.uni-bonn.de> <200502152051.55292.jon@jdh30.plus.com> <1108541998.669.22.camel@localhost> In-Reply-To: <1108541998.669.22.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200502160954.14157.jon@jdh30.plus.com> X-Miltered: at nez-perce with ID 421317F1.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 wrote:01 -unsafe:01 ocaml:01 ocaml:01 repetitive:01 invariants:01 ocamlopt:01 compiler:01 iter:01 polymorphism:01 iter:01 ocamlopt:01 inlining: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: On Wednesday 16 February 2005 08:19, Ville-Pertti Keinonen wrote: > On Tue, 2005-02-15 at 20:51 +0000, Jon Harrop wrote: > > Indeed, I'm in the "remove -unsafe" camp. Even if OCaml only hoisted > > bounds checks in the simplest of cases, I think there would be a strong > > case for removing this option. > > As far as I can tell OCaml *never* eliminates or hoists bounds checks > (or any other repetitive operation), even in the simplest of cases. In most cases, I'm happy with that as the programmer can hoist invariants manually. As Xavier has said before, ocamlopt is designed to compile well- written code. :-) In the case of bounds checking though, only the compiler can do the hoisting. Still, the last time I wrote array-based code it was to demonstrate how much faster tree-based code is. ;-) > It does explicitly use unsafe operations in the standard library, though. I was going to say that this is all the more reason to have a full complement of map/iter/folds in Array and String. Actually, that's not really true as the cost of polymorphism in most of these functions (except String.iter) will dwarf the advantage of removing bounds checking. > ocamlopt doesn't really perform a lot of optimizations. The most > significant ones (inlining, constant folding/value propagation, direct > calls) appear to be done in a single pass (asmcomp/closure.ml). Yes, the performance is astonishingly good considering how elegant the compiler is. I think it relies entirely on the CPU to do dynamic instruction rescheduling for some CPUs (not ARM, of course ;-). -- Dr Jon D Harrop, Flying Frog Consultancy Ltd.