caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: ocaml <caml-list@inria.fr>, yaron jane <yminsky@janestcapital.com>
Subject: Re: [Caml-list] Slow allocations with 64bit code?
Date: Sat, 21 Apr 2007 12:57:04 +1000	[thread overview]
Message-ID: <1177124224.14498.46.camel@rosella.wigram> (raw)
In-Reply-To: <f8560b80704201331j2f8abe89q71b15c0616609f35@mail.gmail.com>

On Fri, 2007-04-20 at 16:31 -0400, Markus Mottl wrote:

> This is only a difference of about 10%, but I have seen more complex
> cases where there are timing differences in excess of 50%, which is
> already pretty substantial.

I am surprised! The 64 bit code is so fast!

You are using 64 bit pointers. They're twice as big as 32 bit
pointers. So every 'box' and all heap slot are double the size.

On a memory intensive operation, you'd expect the 64 bit model
to run at half the speed. In your example:

let () =
  for i = 1 to 100000000 do
    ignore (Int32.add 42l 24l)
  done

it would appear 'ignore' enforces an allocation which is subsequently
garbage collected. So you have both allocation and collection which
hits double the memory than on a 32 bit model. It seems likely
the reason the code is only 10% slower here is that the minor
heap compactor is successfully preventing this code hitting
much memory, possibly keeping the whole thing in cache.

This will be a gc tuning detail.

Try folding over a large list. The 64 bit version should
take twice as long because the memory accesses are the only
part of the operation that takes significant time.
[Everything else should fit in the cache except reading
the list: boxing unboxing the accumulator and invoking
the argument closure should all be effectively zero cost]


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  parent reply	other threads:[~2007-04-21  2:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-20 20:31 Markus Mottl
2007-04-20 20:42 ` [Caml-list] " Jon Harrop
2007-04-21  2:57 ` skaller [this message]
2007-04-22 10:23 ` Xavier Leroy
2007-04-22 16:12   ` Markus Mottl
2007-04-23 20:13     ` Markus Mottl

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=1177124224.14498.46.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=markus.mottl@gmail.com \
    --cc=yminsky@janestcapital.com \
    /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).