mark florisson, 06.10.2011 11:45:
On 6 October 2011 01:05, Robert Bradshaw wrote:
I'm not sure what the overhead is, if any, in calling function pointers vs.
actually linking things together at the C level (which is essentially the
same idea, but perhaps addresses are resolved at library load time rather
than requiring a dereference on each call?)

I think there isn't any difference with dynamic linking and having a
pointer. My understanding (of ELF shared libraries) is that the
procedure lookup table will contain the actual address of the symbol
(likely after the first reference to it has been made, it may have a
stub that resolves the symbol and replaces it's own address with the
actual address), which to me sounds like the same thing as a pointer.
I think only static linking can prevent this, i.e. directly encode the
static address into the call opcode, but I'm not an expert.

Even if it makes a slight difference that the CPU's branch prediction cannot cope with, it's still up to us to decide which code must be inside the module for performance reasons and which we can afford to move outside. Generally speaking, any code section that is large enough to be worth being moved into a separate library shouldn't notice any performance difference through an indirect call.

Stefan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to