tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Small ld.elf_so speed up



On Thu, Apr 01, 2010 at 11:25:13PM +0200, Joerg Sonnenberger wrote:
> On Thu, Apr 01, 2010 at 09:56:17PM +0100, Sad Clouds wrote:
> > Joerg I did a few tests and they seem to indicate that declaring
> > functions 'static' and then exporting them via function pointers is not
> > more expensive, but quite the opposite.
> 
> Your test case isn't really reflecting real world usage as it is blowing
> away the branch caches. It looks quite different in terms of performance
> when you use a tight loop of few functions. The size difference is not
> really a surprise as direct linkage has to export the names etc.
> 
> The function pointer array approach works and is the best way to handle
> modules, e.g. when you have to deal with function pointers anyway.
> Otherwise it is generally an inferior calling convention.

Another thing is that function addresses in shared libraries are normally
resolved the first time they are called. Whereas data references have to
be resolved as load time.
Resolving all function PLT at load time may be advantageous because of
cachE/TLB operations.
Reading the entire elf header into memory with a linear read
(instead of faulting in the pages as needed) and executing the symbol lookup
code for the cache could well be of benefit for many long-lived programs.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index