As a follow-up on https://internals.rust-lang.org/t/request-for-prioritization-fast-thread-locals/13982:
AIUI (perhaps I'm wrong?) the newly stabilized const
initializers make it possible to have faster thread locals by eliminating initialization checks on every call (though it's not documented except in release notes). That still leaves how thread locals are implemented as a potential speed up.
Given the stable existence of const
-initialized thread locals, is stabilization of tls_model - The Rust Unstable Book now viable?
In my case, I'm working on a .so
library that is only ever ld-preloaded, so initial-exec
mode is sufficient, and thread locals are in the hot path. So far I've been relying on cross-language LTO with C code, and leaving thread locals in C, but that's annoying and sometimes too limiting, especially with complex logic. I'd rather not have to write C!