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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 4268DBC57 for ; Wed, 1 Sep 2010 11:54:52 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtMBAB6/fUzRVdQ0imdsb2JhbACgWAgVAQEBCgkMBw8FH6F6iS6CFYZULohUAQEDBYU0BIoR X-IronPort-AV: E=Sophos;i="4.56,303,1280700000"; d="scan'208";a="58168383" Received: from mail-vw0-f52.google.com ([209.85.212.52]) by mail2-smtp-roc.national.inria.fr with ESMTP; 01 Sep 2010 11:54:51 +0200 Received: by vws14 with SMTP id 14so8173329vws.39 for ; Wed, 01 Sep 2010 02:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=IuRGc73wQUKL8hddsBisMj4KbmQwOEq/9dr18t+V/xM=; b=p7jJXAjZUncUYBUqyf1+VH3arS+/87ZlQtP683ST8FdXG8YxCMmA+XtGJeu3tEE02K h8hwm0BclWRnhZvPBDs/Os1e295BCOYtPunoF7f1wxa3PgK26fSN2zqFqrvtU1I3RdRX WuCDn/9mRZyssxUtlnrLgQbuhfLC10mY/7FgM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=nGJluZAGD26azqqUNlPRKi5s5uGKBIkXBzgvuehmHTjQF88vZvmho+c7aupXW9e5Lx OZYDy7DSvRsfq6J8qdMq4allnB+F+1+FdodnZ0wzJfCV9cQfLzTloLPYuwzCjVgjHKgU F3vh9C1DbWK39ooF3g9J/pcVQScwZ6pd35lJI= MIME-Version: 1.0 Received: by 10.220.62.5 with SMTP id v5mr3939407vch.102.1283334890613; Wed, 01 Sep 2010 02:54:50 -0700 (PDT) Received: by 10.220.87.162 with HTTP; Wed, 1 Sep 2010 02:54:50 -0700 (PDT) In-Reply-To: <4C7E0F60.6030406@inria.fr> References: <20100823.140626.634675953541672216.Christophe.Troestler+ocaml@umons.ac.be> <031b01cb4944$77110900$65331b00$@com> <4C7E0F60.6030406@inria.fr> Date: Wed, 1 Sep 2010 05:54:50 -0400 Message-ID: Subject: Re: [Caml-list] Re: Question about float refs. From: Ethan Burns To: Fabrice Le Fessant Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; unboxed:01 ocamlopt:01 compiler:01 compiler:01 unboxed:01 iteration:01 printf:01 printf:01 allocations:01 burns:98 burns:98 wrote:01 caml-list:01 argument:02 slower:02 On Wed, Sep 1, 2010 at 4:31 AM, Fabrice Le Fessant wrote: > If you replace (!r +. 0.) by (!r), you are passing the content of the > reference as an argument to the function. Function arguments are not > unboxed in ocamlopt, so the compiler sees a boxed occurrence of the > float, and so must allocate it. The compiler could decide to have the > float both as boxed and unboxed values, but since the reference is > modified in the loop, there would be a risk of inconsistency, and so the > compiler decides to have only a boxed value, and so the loop is much > slower since it has to allocate the float at each iteration (the > reference itself is probably not allocated). Is there a reason that it can not decide to leave the float unboxed until right before the Printf.printf call? This way it would be modified in the loop without any allocations and then would be placed in a box only when the box is finally needed. Ethan