[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: faster pthread_getspecific



Ulrich Drepper wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hong Zhang wrote:
> 
> > I wonder if it is possible to speed up the pthread_getspecific().
> > Some application requires extreme fast pthread_getspecific().
> > Just an example, Sun JVM makes 1 million calls to it during
> > startup code. I know it sounds insane, but it is reality.
> 
> Start using ELF TLS.  If NPTL is available TLS is, too.  It's the real
> solution to any problem involving pthread_getspecific etc.
> 
> > Here is my quick proposal. Please take a look and see if it fits.
> 
> Show me some numbers.  What improvements do you see?  An improvement
> like that (just simpler) is certainly possible but you've to convince me
> it's really useful.  Just time the startup of your JVM.
> 

pthread_getspecific is *not* the bottleneck of JDK startup. We spent
a lot more time parsing class files. I timed a similar hack with
LinuxThreads before, I went even further as I fetch TLS using 
%gs:[offset] directly in the VM without even going through 
pthread_getspecific() (The TLS offset is pre-calculated when the 
thread is first created, so there is no if-statement or function
call at all when we need the TLS data, only two inlined instructions). 
It makes little difference - the difference is either under 1% 
or statistically insignificant.

thanks,
-hui





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]