> I've heard various people make the claim that using > __thread variables is *much* faster than > pthread_get/setspecific().
Based on how they are designed to work, I would claim that TLS should be at least as fast, and in some cases significantly faster. But I don't remember doing any benchmarking. > However, when I look at > the code emitted as well as the implementation of the > get/setspecific api, it appears to me that _thread > variables might be somewhat faster in binaries but > actually might be slower in shared libraries. I have not looked at the run-time support code for either one. For the compiler code, notice that the compiler can do common subexpression elimination for the TLS variable addresses, but cannot do the same for get/setspecific function calls. To make your TLS code go faster, try to use "static" or "__hidden" variables, as this allows some additional compiler optimizations. > Does anyone have any fine grained experience that > at would help in determining the tradeoffs involved? > Thanks Besides performance, TLS variables are easier to use, and allow the compiler to do some optimizations for you. Peter. This message posted from opensolaris.org _______________________________________________ perf-discuss mailing list perf-discuss@opensolaris.org