While studying the Gentoo prelink guide, I noticed that it is clearly written with 32 bit processors in mind and does not take full advantage of a 64 bit processor running a 64 bit operating system (like Gentoo can be used).
So, if you are using KDE and have an AMD-64 or one of those new INTEL 64 bit processors and are using a 64 bit Gentoo, then read on. (If you are still using a 32 bit Gentoo running on a 64 bit processor, this article may convince you to switch to a pure 64 bit Gentoo.)
The cause why KDE is so goddamn slow on most machines is (besides machines having too little RAM) called "RELOCATIONS".
Relocations occur when an executable or shared library is compiled for the same memory addresses as another one.
When two (or more) such executables/libraries with conflicting address requirements have to be loaded, all of them except for the first have to be relocated. Relocation means:
- It is GODDAMN slow (can take up to several seconds in environments like KDE where many shared libraries are loaded)
- Cannot be shared between processes (or only to a much lesser extent). Which means relocations waste precious memory!
The basic solution to this problem already exists: It's called PRELINKING.
The basic idea of prelinking: Assign a different address range to each shared library in the system, then there will never be an address conflict and thus relocations will never be necessary.
A good plan, but it cannot be executed on a 32 bit processor to its full extent: On 32 bit processors, at most 3 gigabytes of memory are usually available to a process.
And unfortunately, if you add the address space requirements of all shared libraries in your system together, you will typically need more than those 3 GB of addressing space in order to assign a unique address range to each library.
In other words: prelinking will not work on 32 bit systems - at least not to its full extent.
That's why prelinking seems not to gain anything (or at least not too much) when prelinking KDE under a 32 bit operating system.
But on 64 bit systems it can work to its full extent (if you are following the right guide...)!
A full, flat 64 bit address space has the enormous size of 16 exabytes. Even if part of that address space is reserved by the system, there will be plenty of room left in order to assign a different, unique address range to each and every shared library in the system.
Which means your KDE should be lightning fast then - compared to how fast it is now (if you did no prelinking or only that from the official prelinking guide).
What to do:
1. Follow the Gentoo prelink guide http://www.gentoo.org/doc/en/prelink-howto.xml except for the Code listing 3.1 in section "Prelink usage".
2. Instead of the command "prelink -amR" which is suggested in Code listing 3.1 of the guide, use the following command:
Code: Select all
# prelink -afRAnd every time you have installed or updated a package which may contain shared libraries, be sure to run the following command after the emerge operation is complete:
Code: Select all
# prelink -aqR(Hint: Why not making it a cron to be run daily or weekly? However, be sure to check in your cron script that it is not coincidentally run at the same time while an installation is in progress - it could interfere with the installation "merge" or "qmerge" phase of an ebuild.)
But what is the problem with the Gentoo prelink guide?
It is the "-m" switch. This switch is necessary on 32 bit systems for prelinking to work at all (unless you have a minimal installation where all libraries taken together actually fit into a 32 bit addressing space). But it also disables the raw power of prelinking when using a true 64 bit operating system, severely crippling it. So just away with the "-m", and the power is back!
Important notice: Why is this guide tagged as "experimental"? Because I have not tried to do it myself yet! The simple reason: I just haven't got a 64 bit processor...
So ... volunteers wanted!
Who is daring enough to risk the health of his life and his system to prove (or disprove) my fine little theory and to get NOTHING in return (except for some speed gain, perhaps)?
Comments welcome!






