Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!umich!yale!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sunybcs!uhura.cc.rochester.edu!ur-valhalla!micropen!dave From: dave@micropen (David F. Carlson) Newsgroups: comp.unix.questions Subject: Re: Shared libraries Summary: close but no cigars Message-ID: <969@micropen> Date: 10 Jan 90 21:11:08 GMT References: <941@targon.UUCP> <1990Jan9.003208.6061@virtech.uucp> <323@mtndew.UUCP> Organization: Micropen Direct Writing Systems, Pittsford, NY Lines: 39 In article <323@mtndew.UUCP>, friedl@mtndew.UUCP (Steve Friedl) writes: > Ruud Harmsen writes: > > Is it [shared libraries] any slower or faster than the normal way? > > Conor P. Cahill writes: > > Slower link and program initialization, but from then on execution time > > should be the same. > > ... > library live at fixed addresses within the virtual address space, > and the locations of same are set to absolute values within the > program using them. At runtime, the executable is loaded normally, > and calls to the shared library routines depend on the routines > living where they are supposed to (they *better* be there). > Stephen J. Friedl, KA8CMY / Software Consultant / Tustin, CA / 3B2-kind-of-guy Having written a SVr3 graphics shared lib, I believe that Conor is positing that since the shared lib_s.a at ld(1) time will have more symbols it will take longer to load that the normal lib.a. I have not found this to be the case. Because the lib_s.a is *much* less in size, ld(1) has less object code to read (and re-read...) than with lib.a. I have found that a 2X size reduction is *much* faster and well worth the additional symbols the loader must crunch. Program initialization, (contrary to Mr. Friedl), will initialize all *external* symbols within the lib_s (living at a fixed virtual address.) This time is usually small. However, the entire shared library data section is private to each process using the library and must be paged in as normal. This will almost always dominate initialization time, although it should be no slower than normal data section loads. At runtime all shared library calls and all externals used/called by the shared library itself will have one extra level of indirection. This will slow them down by whatever that extra indirect costs on your host. -- David F. Carlson, Micropen, Inc. micropen!dave@ee.rochester.edu "The faster I go, the behinder I get." --Lewis Carroll