Version française
Home     About     Download     Resources     Contact us    
Browse thread
Efficency of varient types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Efficency of varient types
On Sat, 2005-11-26 at 01:31 +0100, Nicolas Cannasse wrote:
> Michael D. Adams wrote:
> > I have recently learned about OCaml and have been impressed by how
> > fast it is in the benchmarks.  However I have discovered that variant
> > types can slow down a program quite a bit.  

> In order to understand what there is such difference, it's useful to 
> learn the ocaml memory model at runtime :

As everyone else says .. but I'll add my piece since I have studied
this particular function in great detail:

http://felix.sourceforge.net/current/speed/en_flx_perf_0005.html

The performance is *heavily* affected by stack space per
function call (in fact, directly proportional to it with
the limits of cache size). Boxing isn't an issue -- any
translator boxing anything in this test is out of the race.

This is a terrible function to choose to compare general
performance, precisely because it is so heavily dominated by
optimisation of stack use. More general benchmarks including
for example Jon Harrop's ray tracer show Ocaml does quite
well, despite boxing. So except in very particular cases,
I wouldn't worry too much about Ocaml being slow.

My own translator Felix (written in Ocaml) wins this test easily 
for unknown reasons -- trouncing even gcc, despite the fact
it actually generates C++ code compiled with gcc using
the same options.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net