4 ms·
Interesting! 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
by theamk 6y ago
Interesting!
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.
Turns out you can'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.
(and this is another case when seemingly simple operation -- getting variable value -- gets internally translated to dozens of operations and a function call)
- LargoLasskhyfv 6y agoWhat do you think of this, then? https://github.com/ssrg-vt/hermitux/wiki/Fast-system-calls-in-dynamically-linked-programs https://github.com/ssrg-vt/hermitux/wiki/Fast-system-calls-i... I just had this in mind because skimmed it a few hours ago in the context of https://ssrg-vt.github.io/hermitux https://ssrg-vt.github.io/hermitux mentioned in https://news.ycombinator.com/item?id=26142285 https://news.ycombinator.com/item?id=26142285
- richardwhiuk 6y agoThat's relying on a unikernel and static linking I think.
- bregma 6y agoThat's one particular implementation for one language runtime one common OS. It's neither a requirement of the C language nor of the ELF executable file format.