caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Fabrice Le Fessant <fabrice.le_fessant@inria.fr>
To: Ethan Burns <burns.ethan@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: Question about float refs.
Date: Wed, 01 Sep 2010 14:29:57 +0200	[thread overview]
Message-ID: <4C7E4745.3070206@inria.fr> (raw)
In-Reply-To: <AANLkTikfYgy5BXCggU6TWmyD7XRRG2T5wspMWV=Ka3BH@mail.gmail.com>

Ethan Burns wrote, On 09/01/2010 11:54 AM:
> On Wed, Sep 1, 2010 at 4:31 AM, Fabrice Le Fessant
> <fabrice.le_fessant@inria.fr> 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.

Yes, that would work. I suppose the reason is just that the analysis to
discover that is much more complex and expensive, and the result is not
always successful, so it was not clear it was worth it for typical OCaml
applications.

--Fabrice


      reply	other threads:[~2010-09-01 12:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19 11:52 Ethan Burns
2010-08-19 13:14 ` [Caml-list] " Lukasz Stafiniak
2010-08-19 13:34 ` David House
2010-08-19 13:49   ` Till Varoquaux
2010-08-23 12:06 ` Christophe TROESTLER
2010-08-23 12:14   ` Ethan Burns
2010-08-23 12:42     ` Sylvain Le Gall
2010-08-23 13:00       ` [Caml-list] " Dmitry Bely
2010-08-31 19:41         ` Jon Harrop
2010-09-01  7:18           ` Dmitry Bely
2010-09-01  7:46             ` Christophe TROESTLER
2010-09-01  8:31             ` Fabrice Le Fessant
2010-09-01  9:54               ` Ethan Burns
2010-09-01 12:29                 ` Fabrice Le Fessant [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C7E4745.3070206@inria.fr \
    --to=fabrice.le_fessant@inria.fr \
    --cc=burns.ethan@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).