caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
Cc: luther@dpt-info.u-strasbg.fr, caml-list@inria.fr
Subject: Re: Cost of polymorphic variants over normal ones.
Date: Thu, 11 Jan 2001 20:14:26 +0100	[thread overview]
Message-ID: <20010111201426.B2615@miss.wu-wien.ac.at> (raw)
In-Reply-To: <20010111235041Z.garrigue@kurims.kyoto-u.ac.jp>; from garrigue@kurims.kyoto-u.ac.jp on Thu, Jan 11, 2001 at 23:50:41 +0900

> However I was surprised to see that with the native code compiler
> polymorphic variants appeared to be faster than normal ones. That
> seems to mean than on modern CPUs, an indirect jump is about 3 times
> more expansive than a conditional, and that polymorphic variants are
> only going to be slow on huge matches. But this was a single, very
> simple benchmark, so I'm not sure this behaviour is stable.

This is also in accordance with a test that I did a few years ago
(in C++): I wondered whether it is more efficient to use function
pointers (jump tables) or case switches to choose the next code part
to be executed. I was surprised to find out that such tables only
started paying off at numbers of around 100 alternatives (I certainly
did this test on Intel chips, but if I remember correctly, it is also
true for Alphas). I guess this may have to do with pipelining and/or
cache effects. Processor experts can probably tell us more...

- Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl



  reply	other threads:[~2001-01-12  9:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-10 18:25 questions about costs of nativeint vs int Norman Ramsey
2001-01-11  9:17 ` Cost of polymorphic variants over normal ones Sven LUTHER
2001-01-11 10:40   ` Alain Frisch
2001-01-11 10:44     ` Sven LUTHER
2001-01-11 14:50   ` Jacques Garrigue
2001-01-11 19:14     ` Markus Mottl [this message]
2001-01-11 18:34 ` questions about costs of nativeint vs int Xavier Leroy
2001-01-11 22:17   ` Norman Ramsey

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=20010111201426.B2615@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=caml-list@inria.fr \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    --cc=luther@dpt-info.u-strasbg.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).