Thread Local in C++ as it is

RU / Day 3 / 10:45 / Track 4

This talk is devoted to such a seemingly well-established feature of C++ as thread_local. Despite that this feature was standardized in C++11, not a lot of people understand what machinery is under the hood. How and in what cases we have this functionality for free. And in which cases heavy artillery used. Here will be considered implementation in Linux, as a platform with the most complex support of this feature of the language. Moreover, a platform that continues to improve it for better performance.

This talk will consider:

  • earlier POSIX solution;
  • implementation in language and 4 "traditional" models of Thread Local;
  • "descriptor" model;
  • specifics in work with thread_local objects and its pitfalls;
  • assembler listings with comments;
  • benchmarks.

Target auditory is experienced developers with some knowledge in x86 assembly. From this talk listeners will take knowledge of what is a lifetime of an object. In what cases it's painless to use this feature, and in what cases we could lose some performance with thread_local. And how could we work around it.

Download presentation