caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Markus Mottl" <markus.mottl@gmail.com>
To: ocaml <caml-list@inria.fr>
Cc: "yaron jane" <yminsky@janestcapital.com>
Subject: Slow allocations with 64bit code?
Date: Fri, 20 Apr 2007 16:31:50 -0400	[thread overview]
Message-ID: <f8560b80704201331j2f8abe89q71b15c0616609f35@mail.gmail.com> (raw)

Hi,

I wonder whether others have already noticed that allocations may
surprisingly be slower on 64bit platforms than on 32bit ones.

I compiled the following code using an OCaml-compiler that generates 32bit code:

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

I ran it on a 64bit platform (Intel(R) Pentium(R) D CPU 2.80GHz), and
it took 0.65 seconds to finish.  Then I recompiled it on this same
platform using an OCaml-compiler that generates 64bit code.
Surprisingly, the resulting executable took 0.72 seconds to run!

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.

Looking at the assembly, there is really no difference in the loop
other than the use of the quad word instructions, which should not
take longer on the exact same platform (i.e. same CPU-frequency).  But
there is a suspicious call to "caml_alloc2", which might cause these
differences.  Can it be that there are alignment problems or similar
in the run time?

In the considerably more complex code I'm currently working on it also
seemed to me that it's allocations (the run time) that cause the
performance difference.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com


             reply	other threads:[~2007-04-20 20:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-20 20:31 Markus Mottl [this message]
2007-04-20 20:42 ` [Caml-list] " Jon Harrop
2007-04-21  2:57 ` skaller
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=f8560b80704201331j2f8abe89q71b15c0616609f35@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=caml-list@inria.fr \
    --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).