Dynamic linking costs two cycles

Oct 03, 2010 18:55

My blog has moved! Read it in the new location here.

It turns out that the overhead of dynamic linking on Linux amd64 is 2 CPU cycles per cross-module call. I usually take forever to get to the point in my writing, so I thought I would change this for once :-)

In MySQL, there has been a historical tendency to favour static linking, in ( Read more... )

freesoftware, mariadb, mysql, performance, programming

Leave a comment

Comments 3

anonymous May 25 2012, 19:23:48 UTC
nice

Reply


anonymous November 23 2013, 04:44:57 UTC
You never got around to elaborating on this part:

"However, on modern systems there are also very serious drawbacks when using static linking"

P.S. please don't talk about packaging advantages -- it's bullshit.

Reply

kristiannielsen November 23 2013, 09:34:51 UTC
It is mostly mixing of static and dynamic linking that is a problem.

One big issue is when you link library A statically, and also link library B
dynamically, and B itself uses A. Then you end up with parts of A from the
static linking of the program and other parts of A from the dynamic linking of
B. This will cause a lot of grief unless the two versions of A are exactly the
same.

If the program is _completely_ statically linked then this problem does not
occur, but that is becoming increasingly difficult to ensure.

Just doing a hostname lookup with glibc will cause dynamic loading of
different resolver libraries, which will crash if the static version of libc
is different from the dynamic one. MySQL/MariaDB, like many other larger
applications, support dynamic loading of plugins, which involves dynamic
linking.

Reply


Leave a comment

Up