|
Boost : |
Subject: Re: [boost] [thread] thread_specific_ptr performance
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-01-09 06:57:33
Am Saturday 09 January 2010 13:58:35 schrieb Andrey Semashev:
>
> The pointer to the thread-specific data is stored in TLS, last time I
> checked. And there's no difference in terms of performance in how you
> store the pointer - via __thread specifier or by manually calling
> pthread APIs. In case of __thread the compiler will generate the
> necessary calls to pthread for you, that all you win, AFAIU.
how do you come to that conclusion?
<<
__thread int *ptr;
int *get_current_thread_data(){
return ptr;
}
>>
<<
_Z23get_current_thread_datav:
.LFB2:
pushl %ebp
.LCFI0:
movl %gs:ptr_at_NTPOFF, %eax
movl %esp, %ebp
.LCFI1:
popl %ebp
ret
>>
boost's find_tss_data on the other hand:
(kcachegrind doesn't let me copy that table, so here is a hand-typed copy of
the most important calls)
find_tss_data
inkl. - exkl. - function
77% - 10% - get_current_thread_data
50% - 15% - boost::call_once
33% - 13% - get_once_per_thread_epoch
31% - 28% - pthread_getspecific
>
> > that would speed up thread_specific_ptr::get() 5-fold according to my
> > profiling.
>
> Hmm, that's unexpected. Could you post a patch to test with?
I don't have a patch, it was an estimation based on the profile above.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk