From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA00930; Tue, 4 May 2004 09:43:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA00983 for ; Tue, 4 May 2004 09:43:09 +0200 (MET DST) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i447h8SH029698 for ; Tue, 4 May 2004 09:43:08 +0200 Received: from pc8-123 (pc8-123 [129.175.8.123]) by lri.lri.fr (8.12.10/jtpda-5.4) with ESMTP id i447PfCr012998 ; Tue, 4 May 2004 09:25:41 +0200 (MEST) Received: from filliatr by pc8-123 with local (Exim 3.35 #1 (Debian)) id 1BKuJB-0004d1-00; Tue, 04 May 2004 09:25:41 +0200 From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <16535.17781.103979.884152@gargle.gargle.HOWL> Date: Tue, 4 May 2004 09:25:41 +0200 To: Jon Harrop Cc: caml-list@inria.fr Subject: Re: [Caml-list] Functors In-Reply-To: <200405031941.46770.jdh30@cam.ac.uk> References: <200405031941.46770.jdh30@cam.ac.uk> X-Mailer: VM 7.03 under Emacs 20.7.2 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) X-MailScanner: Found to be clean X-Miltered: at concorde with ID 4097498C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 caml-list:01 functors:01 functors:01 functorized:01 generic:01 char:01 speedup:01 generic:01 functor:01 inlined:01 lri:01 filliatr:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jon Harrop writes: > > Absolutely, but it can result in a huge performance increase in some cases. > Although these cases may seem to be insignificant to most people > round these parts, I believe they would be a make-or-break for > someone considering ocaml for numerical work. The most obvious > example would be to use functors to partially specialise code for > a primitive vector or geometric type. I have such an example: I recently wrote Ukkonen's suffix tree algorithm in a functorized way, being generic w.r.t. the alphabet and w.r.t. to branching data structure used in the trees. When applied to the particular char/string alphabet, the performance was quite poor w.r.t. some C code implementing the same algorithm. I defunctorized manually and got a 5 times speedup (and the ocaml code now runs almost as fast as the C code, while still generic w.r.t. the tree data type). The main reason was that the most often called function was String.get (millions of times) and through the functor argument it didn't get inlined. -- Jean-Christophe Filliātre (http://www.lri.fr/~filliatr) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners