TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

All about thread-local storage

50 点作者 MaskRay超过 4 年前

3 条评论

theamk超过 4 年前
Interesting!<p>I had known that thread-local variables can be access pretty fast, via dedicated segment register, but I was not clear how can one make this work for dynamically loaded PIC code, like most .so files.<p>Turns out you can&#x27;t. You only get fast access via dedicated register if you are using variable declared in the main program. The .so files have to call special function which does multiple memory lookups to get the actual location, probably severely reducing performance.<p>(and this is another case when seemingly simple operation -- getting variable value -- gets internally translated to dozens of operations and a function call)
评论 #26154140 未加载
评论 #26151733 未加载
zmodem超过 4 年前
<a href="https:&#x2F;&#x2F;www.akkadia.org&#x2F;drepper&#x2F;tls.pdf" rel="nofollow">https:&#x2F;&#x2F;www.akkadia.org&#x2F;drepper&#x2F;tls.pdf</a> is also a great write-up
jstrong超过 4 年前
I have done plenty with threads but never used thread-local storage except when forced to by some other library using it. To me it seems like a bolted-on monstrosity that provides thread safety to thread-naive code after the fact. Am I missing something? Is this a good solution to some problem I haven&#x27;t encountered? Are there situations where the performance of TLS is better than some other solution?
评论 #26156129 未加载
评论 #26155266 未加载