Re:0+0 > 0: C++ thread-local storage performance
by LegionMammal978 on Monday February 17, 2025 @11:25AM
(#43080563)
I think GP is talking about something like this [0]. You let it call __tls_get_addr() once in a constructor, take the offset from %fs, store it in a static variable, and use that offset directly. (The static variable doesn't need to be atomic, since it's only written to once, at dlopen() time.)
[0] https://godbolt.org/z/o6se3je8v