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, 1 Apr 2010 23:25:13 +0200
Joerg Sonnenberger <joerg%britannica.bec.de@localhost> wrote:

> 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.
> 
> Joerg

I did another test, where I replaced a very simplistic "increment by
one" function with "find first set" function.

I defined a total of 20 identical functions - fn_1() to fn_20().
Built shared libraries and executables with 'gcc -O3'.
Based on your suggestion, called 20 function in a loop 1,000,000 times.

Now I'm getting the following results on Pentium 3 machine:

Direct linkage run time:

p3smp$ ./test_direct
time = 653 msec.

Function pointers run time:

p3smp$ ./test_fptr
time = 646 msec.

So, it looks like for larger functions calling them via pointers
results in 7 milliseconds faster run time.

If you're interested I can email you the source files, so you can test
it yourself...


Home | Main Index | Thread Index | Old Index