Re:0+0 > 0: C++ thread-local storage performance
by rwmj on Monday February 17, 2025 @10:50AM
(#43080156)
Is using pthread_key_create / pthread_setspecific / pthread_getspecific / pthread_key_delete better or worse or the same? As I understand it, this is the low level API you were looking for.
[ Parent
| on HN ]
Re:0+0 > 0: C++ thread-local storage performance
by nicbn on Monday February 17, 2025 @10:53AM
(#43080187)
iirc pthread uses the same ABI under the hood, only its compiled into the libc
Re:0+0 > 0: C++ thread-local storage performance
by Sesse__ on Monday February 17, 2025 @01:00PM
(#43081628)
It's much worse, since you can't inline it; it becomes a shared-library call.
Re:0+0 > 0: C++ thread-local storage performance
by yosefk on Monday February 17, 2025 @01:54PM
(#43082096)
Ah, but you can "inline" it by hardcoding its implementation details into your code in the most horrible way imaginable, as suggested by a crafty reader and which, scarily enough, seems to be the fastest and most robust TLS access method from a shared library: https://yosefk.com/blog/cxx-thread-local-storage-performance...