Re: Preliminary ELF prebinding patches available.

From: Matthew N. Dodd <mdodd_at_FreeBSD.ORG>
Date: Sun, 25 May 2003 09:03:24 -0400 (EDT)
On Sun, 25 May 2003, Dag-Erling Smorgrav wrote:
> "Matthew N. Dodd" <mdodd_at_FreeBSD.ORG> writes:
> > I've implemented per-executable ELF prebinding:
>
> Could you explain briefly what prebinding does?

(This isn't as brief as you or I hoped I suspect.)

Relocatable objects (executables and libraries) contain elements that
require relocation before the are usable.  In some cases this relocation
requires symbols to be located and resolved.  Resolving these symbols and
performing the lookups imposes some execution overhead.  By 'prebinding'
we can do as much of this work beforehand and speed up the actual
relocation process.

The short answer is that things like KDE and other library happy
executables take a little less time to load.

Consider this program:

# cat test.c
int main (int argc, char *argv[]) { return (0); }
# cc -o test test.c
# ldd test
test:
        libc.so.5 => /usr/lib/libc.so.5 (0x28076000)
...

Using a simple execloop (1000 iterations) and time(1):

 normal:  0.734u 4.395s 0:07.55 67.8%     13+163k 0+0io 0pf+0w
prebind:  0.396u 3.777s 0:05.26 79.0%     16+173k 0+0io 0pf+0w
 static:  0.000u 0.663s 0:01.06 62.2%     56+186k 0+0io 0pf+0w

Now lets link test.c with lots of useless libraries:

# cc -Wall -o test test.c -lalias -lasn1 -latm -lbsdxml -lbz2 -lc -lc_r
-lcalendar -lcam -lcom_err -lcrypt -lcrypto -ldevinfo -ldevstat -ldialog
-ledit -lfetch -lform -lftpio -lg2c -lgeom -lgnuregex -lhistory -lipsec
-lipx -lisc -lm -lmd -lmenu -lmilter -lmp -lncp -lncurses -lnetgraph
-lopie -lpam -lpanel -lpcap -lradius -lreadline -lroken -lrpcsvc -lsbuf
-lsmb -lssh -lssl -lstdc++ -ltacplus -lufs -lugidfw -lusbhid -lutil -lvgl
-lwrap -lxpg4 -lypclnt -lz -lkvm

(We'll run execloop with only 100 iterations)

 normal:  14.003u 4.263s 0:23.14 78.9%    5+174k 0+0io 0pf+0w
prebind:  1.108u 3.231s 0:05.46 79.3%     6+182k 0+0io 0pf+0w
 static:  0.000u 0.062s 0:00.15 40.0%     66+229k 0+0io 0pf+0w

This is just a quick and dirty example mind you; I should really run
things with 10000 iterations and make execloop do its own timing
statistics etc.

-- 
| Matthew N. Dodd  | '78 Datsun 280Z | '75 Volvo 164E | FreeBSD/NetBSD  |
| winter_at_jurai.net |       2 x '84 Volvo 245DL        | ix86,sparc,pmax |
| http://www.jurai.net/~winter |  For Great Justice!  | ISO8802.5 4ever |
Received on Sun May 25 2003 - 04:03:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:09 UTC