4 ms·
I never investigated TLS perf nearly this deeply, but in a previous DB project we could only salvage perf by banning thread_local in favor of __thread, so it wa
by senderista 2y ago
I never investigated TLS perf nearly this deeply, but in a previous DB project we could only salvage perf by banning thread_local in favor of __thread, so it was impossible for TLS to reference anything but a bare scalar or pointer. We just rolled up all our TLS objects into one struct, heap-allocated that struct in the thread routine, and put a pointer to that struct in TLS. It was easy to write trivial accessors to these objects through the TLS pointer that were always inlined.