I'm using valgrind/callgrind to profile my server code for some optimization. The two most used calls that callgrind is reporting to me (using kcachegrind to view) are _dl_lookup_symbol_x and do_lookup_x. However I have no idea what either of these are and can't seem to find any documentation about them.
Could anyone please tell me where these two functions are used and what they do?
_dl_lookup_symbol_x
is an internal function inside the glibc C runtime library. If you browse the source for glibc, you'll find this comment above the _dl_lookup_symbol_x
definition:
/* Search loaded objects' symbol tables for a definition of the symbol
UNDEF_NAME, perhaps with a requested version for the symbol.
do_lookup_x
is merely a helper function called within the _dl_lookup_symbol_x
function.
I'm no expert on the internals of glibc, but from what I can gather, _dl_lookup_symbol_x
looks for a symbol (such as a function) inside shared libraries loaded by your program.
I don't know why these functions are called so often in your profiling, but at least now you have some clue as to what they do. Your profiling should tell you what functions are responsible for calling _dl_lookup_symbol_x
so often.
Note that it would be normal for _dl_lookup_symbol_x
to be called many times when the program first starts, as the runtime figures out the addresses of shared library functions with a given name. If you're profiling a very short-lived program, then it's not surprising that you'd see that most of the time is spent in internal "housekeeping" functions rather than your own code.