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.1 required=5.0 tests=AWL,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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 30046BC69 for ; Wed, 11 Apr 2007 00:37:55 +0200 (CEST) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.233]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3AMbsq2018992 for ; Wed, 11 Apr 2007 00:37:54 +0200 Received: by wr-out-0506.google.com with SMTP id m59so104472wrm for ; Tue, 10 Apr 2007 15:37:53 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=goSfUOqAvJlrOe3vFn8vQjdMVItQ3/RxEF9I9Dvk07ZW5RcOtH7Gto3ssRVMfBL07y+vlMhjNNsJMqpNqNdSw9mfjqmB2D25mR/ZHQwdP1gHXM/jprTL4fSsiWZwnslf0K60dk9ev/LH67dBybba1yskVfz+ED3ezH0J4a9FDVg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=oDFvI69OpjvBjY1ISIrAxX5EGEnHibq1iJwPG6tzxxI4ueMpzzU9lHI88I3R1L5Is9ysYQ7+CczUPN5vSYGiPB7Q+LbPKJ2KBvQoUfDmcp8nRMsaAwYKoS1Uyb1QEXbdGo0nRCnpaJUmhbrpbwOI1+H3u8Xm5Pfq0EPzJMIF6U4= Received: by 10.78.118.5 with SMTP id q5mr1157291huc.1176244672726; Tue, 10 Apr 2007 15:37:52 -0700 (PDT) Received: by 10.78.194.14 with HTTP; Tue, 10 Apr 2007 15:37:52 -0700 (PDT) Message-ID: <9d3ec8300704101537q30f1c5dsad0b72f0255b3b3d@mail.gmail.com> Date: Wed, 11 Apr 2007 00:37:52 +0200 From: "Till Varoquaux" To: "Jim Grundy" Subject: Re: [Caml-list] Functor Performace Question Cc: caml-list@yquem.inria.fr In-Reply-To: <461C0C71.7060709@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <461C0C71.7060709@intel.com> X-j-chkmail-Score: MSGID : 461C11C2.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 461C11C2.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; functor:01 functors:01 computed:01 ocaml:01 runtime:01 compilation:01 ocaml:01 compiler:01 lri:01 signoles:01 publis:01 signoles:01 functor:01 solver:01 sig:01 Functors are computed at run time... defunctorisation has been studied for Ocaml before [1], however the current implementation of reccursive modules relies on these modules not being defunctorised (The process is being made in a lazy like way at runtime since fix point cannot always be reached during compilation). Like monorphisation defunctorisation is a whole program optimization technique that relies on the existence of a finite number of cases. However ocaml is not about whole program optimizations nor are we dealing with finite universes (in the general case, although more than 90% of the ocaml programs don't uses these corner cases). I doubt we will see these in a caml compiler any time soon. Till P.S.: You should take my answer with a grain of salt: I'm not affiliated in anyways with ocaml development team. [1]http://www.lri.fr/~signoles/publis/signoles06defun.ps.gz On 4/11/07, Jim Grundy wrote: > I have a functor related performance issue. > > I have the following collection of modules and types that we are using > in the implementation of a SAT solver: > > module type Map = sig .. end > > module Nat_map: Map with type key = int > > module type PriorityQueue = sig .. end > > module Make_priority_queue: > functor (M : Map) -> PriorityQueue with type elt = M.key > > module Nat_priority_queue: PriorityQueue with type elt = int > > If we implement Nat_priority_queue in the "right" way as > > module Nat_priority_queue = Make_priority_queue (Nat_map) > > Then I pay about a 3% performance penalty over instantiating the functor > by hand... > > module Nat_priority_queue = struct > module M = Nat_map > (* same code as the body of Make_priority_queue *) > end > > Is there some compiler switch or future version in the works that will > save me from this? > > Thanks > > Jim > > > -- > Jim Grundy, Research Scientist. Intel Corporation, Strategic CAD Labs > Mail Stop RA2-451, 2501 NW 229th Ave, Hillsboro, OR 97124-5503, USA > Phone: +1 971 214-1709 Fax: +1 971 214-1771 > http://www.intel.com/technology/techresearch/people/bios/grundy_j.htm > Key Fingerprint: 5F8B 8EEC 9355 839C D777 4D42 404A 492A AEF6 15E2 > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >