Linux.Desktop.Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Linux.Desktop.Hacks [Electronic resources] - نسخه متنی

Jono Bacon, Nicholas Petreley

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Hack 85. Prelink for Performance

Increase your application's
performance by up to 50%.

One of the problems with
software applications is that they
depend on other software to run. In some cases, this dependency can
be built into the application statically, but in most cases, the
application accesses a range of special libraries for the dependent
functionality. Even the simplest of applications can rely on a huge
range of libraries, and every KDE and GNOME tool needs a number of
dependent programs to run. When an application accesses a library,
special symbols are transferred from the library to the memory that
the application is running in. Unfortunately, this copying process
(called linking) can take quite some time,
particularly with C++-based software.

On the majority of systems, libraries are rarely changed and,
consequently, when a program is run, the process of transferring
these symbols is the same every time. A special tool called
prelink uses this repetition to link once and
store the result of the process in a file that can be executed. This
method, called prelinking, can greatly improve
performance, particularly in C++ software. Many users have
experienced performance improvements of up to 50% in some KDE
software. You'll see less impressive results in
programs that aren't so heavily linked or are
written in a language other than C++.


9.17.1. Run prelink


To use prelink, you need to ensure that you are
running a compiler and libraries that support this feature. You
should aim for a gcc newer than Version 3.1 and
a glibc newer than 2.3. You also need to obtain
the prelink tool from http://www.rpmfind.net/linux/rpm2html/search.php?query=prelink.

Once you have installed prelink, you need to run
the tool on the binaries and libraries that are present on your
system. To do this, you need to add a list of the directories
containing binaries to /etc/prelink.conf. Here
is an example listing of directories to add:

-l /usr/local/sbin
-l /sbin
-l /usr/sbin
-l /usr/local/bin
-l /bin
-l /usr/bin
-l /usr/X11R6/bin
-l /usr/games
-l /usr/local/lib
-l /lib
-l /usr/lib
-l /usr/X11R6/lib

The -l option included at the beginning of each
line ensures that prelink descends recursively
into directories and works on dependent binaries and libraries. This
works under the condition that the directory does not span across
different filesystems or mount points.

To actually perform the prelinking, you need to run the following
command as root whenever you add new software to the system:

foo@bar:~# prelink -afmR

This command prelinks all (-a) binaries and
libraries in the paths within the configuration file. The other
options are explained in man prelink. When you run
the command, it is likely you will see some warnings about the
linking. You can safely ignore these. Some distributions require a
special environment variable to be set to indicate that the
prelinking has been done. You can set this for the current session
with this command:

foo@bar:~$ export KDE_IS_PRELINKED=1

For a more permanent solution, add this to
/etc/environment or to a file appropriate to
your distribution for setting a system-wide variable.


/ 140