Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2005-11-26 (02:54)
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:

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++: