Performance of global access versus thread local
Will Newton
will.newton@linaro.org
Thu Sep 26 07:38:00 GMT 2013
On 25 September 2013 22:38, Roland McGrath <roland@hack.frob.com> wrote:
Hi Roland,
> If you're going to use a DSO like that, you should use LD_BIND_NOW=1 to
> keep startup overhead out of your measured loops. There is no real need to
> use a DSO though. I'm guessing you did so just to make sure the tested
> accesses were the PIC flavors. You can just compile the main program with
> -fPIC for that.
Thanks, I updated the test as attached. Built with:
# gcc -fPIC -O2 main.c -o main -lrt
> For the global case, it would be a hidden global within libc itself.
> So you need the __attribute__ ((visibility ("hidden"))) variant to
> be representative of what the accesses inside libc would do.
I changed this too.
> It's probably better to write the two accesses by hand in assembly--or at
> least show us the disassembly of what you compiled--to be sure they are
> really representative of what the special-case assembly access in libc
> would do.
The numbers I get now are more as expected, although I am still not
sure why the x86_64 TLS version is faster:
x86_64:
TLS ticks per 1000 loops: 0.0000075703 Global ticks per 1000 loops: 0.0000087879
0000000000400790 <tls_access>:
400790: 48 c7 c0 fc ff ff ff mov $0xfffffffffffffffc,%rax
400797: 64 8b 00 mov %fs:(%rax),%eax
40079a: c3 retq
00000000004007b0 <global_access>:
4007b0: 8b 05 8a 08 20 00 mov 0x20088a(%rip),%eax
# 601040 <__TMC_END__>
4007b6: c3 retq
arm:
TLS ticks per 1000 loops: 0.0000043694 Global ticks per 1000 loops: 0.0000035409
000085ec <tls_access>:
85ec: 4b03 ldr r3, [pc, #12] ; (85fc
<tls_access+0x10>)
85ee: ee1d 2f70 mrc 15, 0, r2, cr13, cr0, {3}
85f2: 447b add r3, pc
85f4: 681b ldr r3, [r3, #0]
85f6: 58d0 ldr r0, [r2, r3]
85f8: 4770 bx lr
85fa: bf00 nop
85fc: 00008a2a .word 0x00008a2a
00008614 <global_access>:
8614: 4b01 ldr r3, [pc, #4] ; (861c
<global_access+0x8>)
8616: 447b add r3, pc
8618: 6818 ldr r0, [r3, #0]
861a: 4770 bx lr
861c: 00008a1a .word 0x00008a1a
--
Will Newton
Toolchain Working Group, Linaro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 1117 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20130926/54095ea3/attachment.bin>
More information about the Libc-alpha
mailing list