develooper Front page | perl.bootstrap | Postings from July 2000

The virtues of vtables

Tim Bunce
July 24, 2000 09:19
The virtues of vtables
Message ID:
On Mon, Jul 24, 2000 at 04:57:19PM +0100, Michael Stevens wrote:
> We need a common subset of functionality, and we need to make that
> available from one or more backend libraries, or there's no point to
> the whole thing. 
> Ideally it needs to be at least as efficent as using the code directly.
> Tricky, without cpp evilness, or something very fun in our 
> perl-implementation-> real code translator, and we can't make decisions
> without knowing how that would be done.

Chip, Nick, myself and some others had an interesting chat at the p5p party.

The gist was that function calls in C are cheap, *very* cheap, these days.
When calling cached code they're often cheaper than a simple if statement
(owing to bubbles in the instruction cache pipeline).

Furthermore, making function calls that then contain if statements may
still be a net win because of the greater density of code in the cache
(relative to having code generated from many macros that contain many
in-line if statements).

[Note that Nick and others have considerable up-to-date experience in
these areas. My experience is rather dated now.]

The point is that a clean and simple vtable style approach (in C) can
be as fast, and possibly faster, than the ``laden with macros to avoid
function calls'' approach used in perl5.

A clean vtable style approach makes pluggable data type implementations
and pluggable backend libraries relatively simple.

Tim. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About