Last week, we identified a bug in Qt with Olivier‘s new signal-slot syntax. Upon further investigation, it turns out it’s not a Qt issue, but an ABI one. Which prompted me to investigate more and decide that dynamic libraries need a big overhaul on Linux.
tl;dr (a.k.a. Executive Summary)Shared libraries on Linux are linked with -fPIC, which makes all variable references and function calls indirect, unless they are static. That’s because in addition to making it position-independent, it makes every variable and function interposable by another module: it can be overridden by the executable and by LD_PRELOAD libraries. The indirectness of accesses is a performance impact and we should do away with it, without sacrificing position-independence. Plus, there are a few more actions we should take (like prelinking) to improve performance even further.Jump to existing or proposed solutions, Google+ discussion.
DetailsNote: in the following, I will show x86-64 64-bit assembly and will restrict myself to that architecture. However, the problems and solutions also apply to many other architectures, like x86 and ARM, which should make you consider what I say. The only platform that this mostly does not apply to is actually IA-64.
The basicsImagine the following C file, which also compiles in C++ mode:extern void *externalVariable;
extern void externalFunction(void);
void myFunction()
{
externalFunction();
externalVariable = &externalFunction;
}Read more: Thiago Macieira's blog
QR:
tl;dr (a.k.a. Executive Summary)Shared libraries on Linux are linked with -fPIC, which makes all variable references and function calls indirect, unless they are static. That’s because in addition to making it position-independent, it makes every variable and function interposable by another module: it can be overridden by the executable and by LD_PRELOAD libraries. The indirectness of accesses is a performance impact and we should do away with it, without sacrificing position-independence. Plus, there are a few more actions we should take (like prelinking) to improve performance even further.Jump to existing or proposed solutions, Google+ discussion.
DetailsNote: in the following, I will show x86-64 64-bit assembly and will restrict myself to that architecture. However, the problems and solutions also apply to many other architectures, like x86 and ARM, which should make you consider what I say. The only platform that this mostly does not apply to is actually IA-64.
The basicsImagine the following C file, which also compiles in C++ mode:extern void *externalVariable;
extern void externalFunction(void);
void myFunction()
{
externalFunction();
externalVariable = &externalFunction;
}Read more: Thiago Macieira's blog
QR: