Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Peng Zang <peng.zang@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Width subtyping
Date: Mon, 1 Jun 2009 13:04:18 -0400	[thread overview]
Message-ID: <200906011304.20561.peng.zang@gmail.com> (raw)
In-Reply-To: <008901c9e2c4$46975500$d3c5ff00$@allsopp@metastack.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Monday 01 June 2009 10:21:36 am David Allsopp wrote:
> Dario Teixeira wrote:
> > Thanks -- that is also an interesting solution.  I'm guessing it will
> > be faster, though it might consume more memory in cases where only one
> > field is actually used.  I'll have to try it side-by-side with the
> > object based solution to see how they compare in the real world with my
>
> So as I wouldn't immediately be told "the overhead is irrelevant", I ran a
> "quick" benchmark before my last post. I compared summing 7 million
> 3-int-field records and 7 million 3-int-field objects using names a, b, c.
> On my machine, averaged out and with enough RAM that neither paging nor the
> GC get in the way, objects were nearly 3 times slower. I then tried with
> 10-int-field records and objects - in this case, objects were just over 4
> times slower (read on). This was in bytecode - I didn't bother with native
> code.
>
> The overhead of an object is 2 words (one contains tracking information
> about the actual class of the object and the other is a unique identifier)
> + (I think) 1 extra word for every field (because each int is boxed in a
> 1-tuple so that its tag can be recorded). Importantly, accessing fields in
> a record is an O(1) operation but for objects it's O(log n) for the number
> of fields because a binary search is done to locate the field with the
> correct tag. ocamlopt may of course optimise this search by caching the
> absolute index of the field in a "recognised" object layout; I didn't look
> in the compiler. My test between 3 and 10 fields would suggest that this
> optimisation does not apply in bytecode.
>
>
> David

This also matches what I've seen.  It seems many optimizations are not 
performed in bytecode.  As a result, the performance characteristics of 
objects change dramatically when compiled to native code.  In my experience 
objects incur a 20% hit on runtime in native code.

Peng
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFKJAoUfIRcEFL/JewRAjlOAJ98T4OTRDy9+TxhzZ6bVuzu7pFjHACdFreL
gFn1gN+whdEntNO2JcZguzQ=
=1FQS
-----END PGP SIGNATURE-----


  reply	other threads:[~2009-06-01 17:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-01 13:56 Dario Teixeira
2009-06-01 14:21 ` David Allsopp
2009-06-01 17:04   ` Peng Zang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-05-31 23:08 Dario Teixeira
2009-06-01 11:34 ` Yaron Minsky
2009-05-30 15:36 Dario Teixeira
2009-05-31  5:18 ` Dave Benjamin
2009-05-31  7:34   ` David Allsopp
2009-06-01  4:21   ` Jacques Garrigue
2009-05-29 15:50 Dario Teixeira
2009-05-29 15:45 Dario Teixeira
2009-05-29 16:06 ` Till Varoquaux
2009-05-29 15:38 Dario Teixeira
2009-05-29 14:10 Dario Teixeira
2009-05-29 14:21 ` [Caml-list] " Jacques Carette
2009-05-29 14:43 ` David Allsopp
2009-05-29 15:33 ` Richard Jones

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=200906011304.20561.peng.zang@gmail.com \
    --to=peng.zang@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