tech-userlevel archive

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

Re: Small ld.elf_so speed up



> OK I see. With 20 functions in a tight loop, direct linkage is about
> 23% faster on my machine.

Looks like GCC optimised away those simple functions calls.

I changed all 20 functions to the following format, they have
'noinline' attribute applied to them and contain 'asm' to force GCC to
emit a real function call:

int fn_1(int n) __attribute__((noinline));
int fn_1(int n) { asm (""); return n++; }
...
int fn_20(int n) __attribute__((noinline));
int fn_20(int n) { asm (""); return n++; }

I also added calls to clock_gettime() before and after the main loop,
in order to get accurate run time (not load time) timing.

Direct linkage with 1,000,000 function calls:

p3smp$ gcc -O1 test_direct.c -o test_direct
p3smp$ ./test_direct
time = 160 msec.


Function pointers with 1,000,000 function calls:

p3smp$ gcc -O1 test_fptr.c -o test_fptr
p3smp$ ./test_fptr
time = 166 msec.

That's about 4% slower.


Home | Main Index | Thread Index | Old Index