caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Brian Hurt <bhurt@spnz.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Object-oriented access bottleneck
Date: Mon, 8 Dec 2003 20:02:28 +0100	[thread overview]
Message-ID: <20031208200228.A26466@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.LNX.4.44.0312081136040.5009-100000@localhost.localdomain>; from bhurt@spnz.org on Mon, Dec 08, 2003 at 11:51:35AM -0600

> How much slower is a member function call compared to a non-member 
> function call?  I was given the impression that it was signifigantly 
> slower, but you're making it sound like it isn't.

In the non-member case, it depends very much whether the function
being called is statically known or is computed at run-time.  In the
first case, a call to a static address is generated.  In the latter
case, a call to a function pointer is generated.

Here are some figures I collected circa 1998 on a PowerPC 603 processor:

   type of call              cost of call

inlined function               0 cycles
call to known function         4 cycles
call to unknown function      11 cycles
method invocation             18 cycles

I'm pretty sure that more modern processors have a bigger gap between
the "call to known function" and "call to unknown function" cases.

So, as you can see, method invocation isn't much more expensive than a
call to an unknown function, but is significantly more expensive than
a call to a known function.  

In source-level terms, replacing an object by a record of functions
isn't going to make a major performance difference (the applications
of the functions fetched from the record fall in the "call to unknown
function" case), while getting rid of dynamic dispatch entirely and
just call known functions is a much bigger improvement.

Hope this clarifies the issue.

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2003-12-08 19:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-07  2:39 Nuutti Kotivuori
2003-12-07  2:59 ` Nicolas Cannasse
2003-12-07 11:22   ` Benjamin Geer
2003-12-07 14:12     ` Nicolas Cannasse
2003-12-07 18:04   ` Nuutti Kotivuori
2003-12-07 10:27 ` Jacques Garrigue
2003-12-07 19:46   ` Nuutti Kotivuori
2003-12-08  1:07     ` Jacques Garrigue
2003-12-08 15:08       ` Nuutti Kotivuori
2003-12-08 15:42         ` Richard Jones
2003-12-09  0:26           ` Nicolas Cannasse
2003-12-09 12:10             ` Nuutti Kotivuori
2003-12-09 13:17               ` Olivier Andrieu
2003-12-09 13:53                 ` Nuutti Kotivuori
2003-12-08 17:51       ` Brian Hurt
2003-12-08 18:19         ` brogoff
2003-12-08 20:09           ` Brian Hurt
2003-12-08 19:02         ` Xavier Leroy [this message]
2003-12-08 21:37           ` Brian Hurt
2003-12-08 21:06             ` Nuutti Kotivuori
2003-12-08 22:30             ` malc
2003-12-07 18:23 ` Brian Hurt
2003-12-07 18:14   ` Nuutti Kotivuori
2003-12-07 19:30     ` Brian Hurt
2003-12-07 23:50       ` Abdulaziz Ghuloum
2003-12-08 17:29         ` Brian Hurt
2003-12-08 18:48           ` Nuutti Kotivuori
2003-12-08 10:17       ` Nuutti Kotivuori
2003-12-08 19:51       ` skaller

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=20031208200228.A26466@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=bhurt@spnz.org \
    --cc=caml-list@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).