mailing list of musl libc
 help / color / mirror / code / Atom feed
* Question re: dynamic linking in musl
@ 2015-05-27 10:08 Alex Dowad
  2015-05-27 10:40 ` Alexander Monakov
  0 siblings, 1 reply; 11+ messages in thread
From: Alex Dowad @ 2015-05-27 10:08 UTC (permalink / raw)
  To: musl

Hi,

I'm just dealing with a problem whereby rrdtool is spending >90% of its runtime in
musl's dynamic linker (this is on Alpine Linux). This is making it too slow to do
what we need it to do.

After perusing some hotspots in dynlink.c (as measured by callgrind), there is
something which looks like a big opportunity for optimization. I hope I'm not wrong.
I probably am. I don't understand the code very well.

do_relocs is called 3 times for each binary which needs relocation (including the main
program and all its dependencies). Once for all the relocations in .rel.dyn, one
for those in .rel.plt, and one for... something else. Haven't looked it up, not
important right now.

do_relocs iterates through all those relocations, and calls find_sym for each one
to look up where the desired function, or variable, etc. can be found.

find_sym iterates through *each* binary which has been loaded, including *all*
the recursive dependencies, and does a hash lookup in each one to see if the
desired symbol can be found.

(Well, that's not quite right; for certain types of relocations, it skips the
head of the list of binaries.)

NOW: Is there any reason why dso->deps could not be used to search for symbols *only*
in the dependencies of the binary which is currently being relocated?

For example, rrdtool has dependencies on librrd, libxml, pango, libpng, libintl,
libgobject, libharfbuzz, libfontconfig, libfreetype, libX11, libexpat, etc. etc. etc.
When unresolved symbols in libX11 are being looked up, musl will start looking in
librrd, right at the top of the list. But there's no way it will find any of
libX11's relocations in librrd. The dependencies of libX11 are right down close
to the *bottom* of the list.

To add insult to injury, that wasteful lookup process will be repeated for each and
every of the more than 1000 relocations in libX11.

Hoping someone smarter than me can explain things... Thanks, AD


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-05-28 14:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 10:08 Question re: dynamic linking in musl Alex Dowad
2015-05-27 10:40 ` Alexander Monakov
2015-05-27 11:18   ` Alex Dowad
2015-05-27 13:01     ` Alexander Monakov
2015-05-27 13:09       ` Timo Teras
2015-05-27 13:15         ` Alex Dowad
2015-05-27 13:23           ` Timo Teras
2015-05-27 14:06             ` Szabolcs Nagy
2015-05-27 14:06             ` Rich Felker
2015-05-28 14:03               ` Natanael Copa
2015-05-27 13:06     ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).