Version française
Home     About     Download     Resources     Contact us    
Browse thread
Memory allocation nano-benchmark.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@j...>
Subject: Re: [Caml-list] Memory allocation nano-benchmark.
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.