From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 7C9EBBBAF for ; Wed, 6 Aug 2008 23:47:28 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AksEAO+4mUjAXQIniGdsb2JhbACBWI9kAQEBDyCbcw X-IronPort-AV: E=Sophos;i="4.31,316,1215381600"; d="scan'208";a="15775351" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Aug 2008 23:47:28 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m76LlRCG019969 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 6 Aug 2008 23:47:27 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhAkAEG4mUjVBJXyWmdsb2JhbACBWI9aARYGBQYTBJt0 X-IronPort-AV: E=Sophos;i="4.31,316,1215381600"; d="scan'208";a="28001376" Received: from outmailhost.telefonica.net (HELO ctsmtpout2.frontal.correo) ([213.4.149.242]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Aug 2008 23:47:27 +0200 Received: from NANA.localdomain (88.0.116.172) by ctsmtpout2.frontal.correo (7.2.056.6) (authenticated as ferferse$telefonica.net) id 4899EFD60008604F for caml-list@inria.fr; Wed, 6 Aug 2008 23:47:26 +0200 Received: from mfp by NANA.localdomain with local (Exim 4.69) (envelope-from ) id 1KQqqs-0000FQ-5X for caml-list@inria.fr; Wed, 06 Aug 2008 23:47:26 +0200 Date: Wed, 6 Aug 2008 23:47:25 +0200 From: Mauricio Fernandez To: caml-list@inria.fr Subject: Re: [Caml-list] native vs bytecode Message-ID: <20080806214725.GG6952@NANA.localdomain> Mail-Followup-To: caml-list@inria.fr References: <74a4f4670808061258q30513bbdl446240feab3fdc36@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74a4f4670808061258q30513bbdl446240feab3fdc36@mail.gmail.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Miltered: at concorde with ID 489A1BEF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bytecode:01 ocaml:01 ocaml:01 bytecode:01 frisch:01 stdlib:01 trivial:01 dispatching:01 stdlib:01 hashtbl:01 fda:98 wrote:01 binaries:01 stack:01 dynamically:01 On Wed, Aug 06, 2008 at 03:58:22PM -0400, Ben Aurel wrote: > hi > As I try to acquire more knowledge about Ocaml I made a bit of an > unpleseant discovery today. I always was fascinated by the execution > performance of Ocaml. But now I've learned, that this is only true for > native binaries and I'm a little confused now: > > - is it possible to dynamically load native libraries into a native program? > > - is it possible to dynamically load bytecode libraries into a native program? > > - is it possible to dynamically load native libraries into a bytecode program? > > - is it possible to dynamically load bytecode libraries into a bytecode program? This has already been addressed by Alain Frisch. I'd only add to his answer that OCaml 3.11 is being released soon (probably later this month): http://groups.google.com/group/fa.caml/tree/browse_frm/thread/15126f960406e056/531fda06c1da700e?rnum=1&_done=%2Fgroup%2Ffa.caml%2Fbrowse_frm%2Fthread%2F15126f960406e056%3F#doc_e038a89c482c0c68 > - Are there any performance test that shows how bytecode programs > stack up agains dynamic languages like ruby, perl and python? I've compared some OCaml bytecode programs to their Ruby equivalents, and have often found them to be 2 to 5 times faster _if_ you're not using expensive stdlib functions which are implemented in OCaml in the first case and happen to be written in C in Ruby's core classes (for instance, Array.sort vs. Array#sort; the latter is faster unless the comparison function, or #<=> method, isn't trivial[1]). I also compared OCaml bytecode with Ruby 1.9 using some simple micro-benchmarks, and found basic functionality (integer arithmetic, loops, etc.) to be about as fast (not surprising since the underlying VMs are quite similar for such things). Still, overall OCaml bytecode can be faster than Ruby 1.9 (which can itself be substantially faster than 1.8 sometimes) because in the latter method dispatching is quite expensive, in contrast to OCaml, where you're applying known functions most of the time. This holds even in Ruby's best case (method cache hit). [1] this deficiency is addressed by using an external C function, the same way Ruby does. Fortunately, there are few such cases: in the stdlib, some Array operations (copy, sub and some other operations), the above-mentioned sort functions, and maybe Hashtbl come to mind. -- Mauricio Fernandez - http://eigenclass.org