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_xis 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_xdefinition:do_lookup_xis merely a helper function called within the_dl_lookup_symbol_xfunction.I’m no expert on the internals of glibc, but from what I can gather,
_dl_lookup_symbol_xlooks 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_xso often.Note that it would be normal for
_dl_lookup_symbol_xto 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.