discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static and shared libraries, stand-alone GNUstep applications


From: M. Grabert
Subject: Re: static and shared libraries, stand-alone GNUstep applications
Date: Sat, 28 Feb 2004 02:38:40 +0000 (GMT)

On Fri, 27 Feb 2004, [iso-8859-1] René Berber wrote:

> On 2004-02-27 16:54:07 -0600 M. Grabert <xam@cs.ucc.ie> wrote:
>
> [snip]
> > The binary was fully functional (but took longer to start up, because of
> > the much larger file size).
>
> Interesting.
>
> There's an option used by some Gentoo users,
> http://www.gentoo.org/doc/en/prelink-howto.xml, it's from a person at
> RedHat, the download points to ftp://people.redhat.com/jakub/prelink.

They are talking about C++ object prelinking, this is an entirely different
issue. Well, perhaps not entirely.

> The Gentoo page says it makes applications load faster, and from the 
> description
> (and name) it seems to create an executable with all the libraries 
> "pre-loaded".

Generally (and theoretically) speaking, yes. Static binaries start usually
faster. But not in all situations, especially if it is a slow system.
But there are also other factors (see further below).

Subsequent runs of the programme start indeed very fast (since it's
cached in the buffer), but the initial run is way slower on this old machine.

> I have not used it, but if it works as advertised it would be equivalent
> to link with static libraries.

Prelinking makes lots of sense if you are dealing with *lots* of custom
libraries that have to be (dynamically) loaded, e.g. with StarOffice or KDE.

I don't think the performance improvement of using statically linked
libraries is really significant here, but the fact that static binaries
consume more RAM and always need to load all (statically linked) libraries
at one time from disk in form of a single executable.


Eg. I'm using about 8 libraries beside libgnustep-base in my GNUstep app.
They include dynamic versions of libc, libm and libz, which are
definitely already in the systems cache or RAM, since almost all
(dynamically linked) programmes require these libraries.
If you are running a desktop system, it is also likely that you also have
programmes running that use libjpeg, libpng and libtiff.
And some network daemons probably in the background probably use libssl.
These are all libraries that GNUstep uses.

Basically on 'normal' system those popular libraries are already loaded
into RAM and are being used, and the only thing that needs to be loaded
from the hard drive is your (small) dynamically linked GNUstep programme and the
libgnustep* libraries (and perhaps one or two other libraries).

But when you statically link a GNUstep app, suddenly all those popular
libraries you are using in you programme are also statically included in
your executable and they all have to be loaded from disk.


So static binaries load faster. But only if you are using lots of
unpopular/custom libraries. If you are only using some 'standard' libraries,
dynamically linked programmes start faster.


Greetings,
  Max




reply via email to

[Prev in Thread] Current Thread [Next in Thread]