From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 07736BB9C for ; Sat, 26 Nov 2005 03:54:27 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAQ2sQXF010030 for ; Sat, 26 Nov 2005 03:54:26 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA23746 for ; Sat, 26 Nov 2005 03:54:25 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAQ2sNHN004954 for ; Sat, 26 Nov 2005 03:54:24 +0100 Received: from rosella (ppp33-4.lns1.syd6.internode.on.net [59.167.33.4]) by smtp1.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id jAQ2sGMt073208; Sat, 26 Nov 2005 13:24:18 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Efficency of varient types From: skaller To: Nicolas Cannasse Cc: "Michael D. Adams" , caml-list@inria.fr In-Reply-To: <4387ACC9.2040107@motion-twin.com> References: <4387ACC9.2040107@motion-twin.com> Content-Type: text/plain Date: Sat, 26 Nov 2005 13:54:16 +1100 Message-Id: <1132973656.21350.117.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4387CE62.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4387CE5F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 cannasse:01 ocaml:01 ocaml:01 model:01 runtime:01 stack:01 stack:01 gcc:01 gcc:01 wrote:01 wrote:01 sourceforge:01 sourceforge:01 flx:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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 Felix, successor to C++: http://felix.sf.net