|
|
Log in / Subscribe / Register

Is pre-linking worth it?

Is pre-linking worth it?

Posted Jul 15, 2009 22:19 UTC (Wed) by nix (subscriber, #2304)
In reply to: Is pre-linking worth it? by arjan
Parent article: Is pre-linking worth it?

That figure is surprising to me, as it would imply that 20% of your
average program was relocation sections, or that they are very scattered
in the executable, which should not be the case. (As relocations are
incurred disproportionately at startup, it might mean simply that you ran
a lot of programs that exited fast, but those would be in cache and thus
not read from the disk.)

(glibc is linked with --bind-now, but that doesn't affect things much: it
causs immediate relocation, but only of those symbols in glibc that are
used, not of all of them.)


to post comments

Is pre-linking worth it?

Posted Jul 16, 2009 3:21 UTC (Thu) by tbird20d (subscriber, #1901) [Link] (6 responses)

Reducing "payload" by 20% doesn't mean that 20% of the whole program is relocation, merely 20% of what gets loaded. Due to demand paging, rarely does the entire program get loaded from disk. Also, I'm not sure, but it may be that doing ordinary linking requires pages to be loaded for relocation which otherwise would not have been loaded at all.

Is pre-linking worth it?

Posted Jul 16, 2009 3:35 UTC (Thu) by nix (subscriber, #2304) [Link] (5 responses)

Yes, but even so, 20% is a terribly high figure. The test program must
have called a very large number of symbols per text page for this to be
true. (Possibly it was a very small test binary, /bin/cat or something
like that: the essentially random ordering of symbols in glibc would have
required many of its pages to be faulted in for relocation processing,
leading to an artificially high figure.)

Is pre-linking worth it?

Posted Jul 16, 2009 4:35 UTC (Thu) by arjan (subscriber, #36785) [Link] (2 responses)

this wasn't a test program; it was a whole OS boot + login into the UI/desktop.

Is pre-linking worth it?

Posted Jul 16, 2009 4:39 UTC (Thu) by arjan (subscriber, #36785) [Link]

(and yes, I was surprised by how much it was as well, but it made it a no-brainer to turn on for us)

Is pre-linking worth it?

Posted Jul 23, 2009 16:57 UTC (Thu) by jgg (subscriber, #55211) [Link]

I've got similar results from some of my embedded work too. prelinking saves about 3-5% of system ram in my cases because it prevents paging in of the relocation and symbol tables, and it doesn't dirty as many pages in the shared libraries.

20% doesn't seem that surprising to me, glibc for instance has 50k you have to load just to do symbol resolution. You'd only need to fault in 250k of text from glibc to get to 20% overhead. Even my desktop has only faulted in 224kb of glibc.

Is pre-linking worth it?

Posted Jul 16, 2009 11:22 UTC (Thu) by mjthayer (guest, #39183) [Link] (1 responses)

Perhaps because the pre-linking made it unnecessary to open certain on-disk library files to do the symbol look ups, putting that off until symbols from them were actually needed? Just a guess.

Is pre-linking worth it?

Posted Jul 16, 2009 17:51 UTC (Thu) by nix (subscriber, #2304) [Link]

No, relocations within a given library would happen when that library was
opened: the relocation process cannot trigger additional library opens
that weren't already going to happen.

In any case, most library opens during system startup will be driven by
DT_NEEDED, in which case the whole dependency tree of them gets mmap()ed
immediately.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds