Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
questions about costs of nativeint vs int
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-01-12 (09:03)
From: Markus Mottl <mottl@m...>
Subject: Re: Cost of polymorphic variants over normal ones.
> 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,,