How to make software open much faster

trollboy
  13 years ago
  65

As an impatient S.o.B. with the attention span of a hyperactive mayfly, one of my bugbears with Linux, specifically Linux Mint Debian Edition in my case, is how long some applications take to start up when I select the menu option. On my laptop for example, Libre Office Writer takes over twenty five seconds. That doesn't sound like a huge amount of time and in the grand scheme of things it probably isn't; but it feels like an eternity when you are waiting for an application to open.

If you want to find out how long twenty five seconds actually is, try the following, simple experiment.

Get into your car at 3am and drive around a quiet neighbourhood. Give a blast on your horn that lasts for twenty five seconds. You will be truly amazed at how long it is!

Seriously, don't do that as depending on the neighbourhood, you may get into trouble with the law, or shot or both!

LibreOffice writer now starts up on my laptop in less than five seconds and most other programs have had a similar boost. And it was easy to achieve.

When starting any Linux application, the biggest chunk of time by far is spent working out which shared libraries are needed by the application and which are needed by those and so on and so on. What we need then is a way to speed up or avoid this process. Fortunately, there is a wonderful utility called prelink which will do the job perfectly.

The following is how I set it up in LMDE; the process should be the same in the other Mint editions as I know it works the same for Xubuntu.

  1. Install prelink by opening a terminal and running the command "sudo apt-get install prelink" acceptting any dependencies. You don't need the quotes.
  2. Turn on prelinking by editing /etc/default/prelink as root and changing the line that says PRELINKING=unknown to PRELINKING=yes
  3. Initialise the prelink databse by running the command "sudo /etc/cron.daily/prelink" in a terminal. This will take quite a while to complete but thereafter will update very quickly every day. Once again, you don't need the quotes around the command.

That's it! It really is that easy.

Comments
ghasafello 9 years ago

Thanks!!


MagicMint 9 years ago

“Though prelink does provide a benefit, it may be a bit hard to justify as time goes on.” See http://lwn.net/Articles/341244/ before you decide to do that. With an SSD, you don’t need this anymore.


ack0329 9 years ago

Awesome Thanks


trollboy 9 years ago

No. It's a cron job which is similar to a scheduled task in the Windows world.


1OfUs 10 years ago

EXELENT !!!
Do I must start command "sudo /etc/cron.daily/prelink" every time when Im login to os?


cyberschelm 10 years ago


Woot, thanks! My libreOffice stuff and firefox open in 2 secs now :)


Tiens 10 years ago

Wow this made a huge difference thanks!


powerhouse 11 years ago

Thanks, even on an already fast machine I was able to speed up some applications, notably gimp. Great advise!


Gabor 12 years ago

Workaround for the '134' bug:
1. sudo chmod 666 /etc/prelink.conf
2. sudo prelink -amvR
3. take the program from the last 'Prelinking ...' output before it crashed and
sudo echo '-b /path/to/program' >> /etc/prelink.conf
4. repeat 2 and 3 until it runs through


trollboy 12 years ago

james3mc: It means it can't link that item. It should be OK to ignore


trollboy 12 years ago

hithirdwavedust:I have opuntia but not specifically the prickly pear. On your main question, I have no idea I'm afraid but I thought it generated on disk tables of links


hithirdwavedust 12 years ago

This is incredibly interesting; do you know of any security ramifications of prelinking? Also, does the linking reside in main memory as the machine runs?

On a totally different subject, do you have a prickly pear in your collection of cacti?


james3mc 12 years ago

On my system, initialise eventually fails. My prelink log ends with this ...

2012-02-10 09:35:37 prelink: /usr/bin/mplayer: Cannot prelink against non-PIC shared library /usr/lib/i686/cmov/libpostproc.so.52
prelink.bin: ../../src/conflict.c:763: prelink_build_conflicts: Assertion `j < ndeps' failed.
Prelink failed with return value 134

Any ideas what this actually means?
James


Boringbytes 12 years ago

I followed your recommendation for helping applications open faster.
While some applications were not noticeably affected, others, like LibreOffice, and Gimp showed a drastic improvement in start-up speed. Following the steps in your tutorial it was easy, and fast to set up prelinking.


hitchawk 13 years ago

Thanx for the Tutorial, I have carefully followed the steps,but have encountered this problem and would like to ask if anyone can tell me what is going wrong, and how i can correct it.

bilbo@bilbo-laptop ~ $ sudo /etc/cron.daily/prelink
[sudo] password for bilbo:
/etc/cron.daily/prelink: line 55: 1682 Aborted /usr/sbin/prelink -a $PRELINK_OPTS >> /var/log/prelink.log 2>&1

Many thanks :)


brenlla 13 years ago

On my LMDE 1109 I have problems. Here is my prelink.log:
/usr/sbin/prelink -a -mR -T -f
2011-12-14 05:15:35 prelink: /usr/lib/icedove/icedove-bin: Could not find one of the dependencies
2011-12-14 05:15:35 prelink: /usr/lib/klibc/bin/losetup: Using /lib/klibc-gj8Lrm8UlC498y56mvS0YY96gps.so, not /lib/ld-linux.so.2 as dynamic linker
2011-12-14 05:15:35 prelink: /usr/lib/klibc/bin/dmesg: Using /lib/klibc-gj8Lrm8UlC498y56mvS0YY96gps.so, not /lib/ld-linux.so.2 as dynamic linker
(...)
2011-12-14 05:15:35 prelink: /usr/lib/klibc/bin/reboot: Using /lib/klibc-gj8Lrm8UlC498y56mvS0YY96gps.so, not /lib/ld-linux.so.2 as dynamic linker
2011-12-14 05:15:39 prelink: /usr/lib/libbonobo-activation.so.4.0.0: Not enough room to add .dynamic entry
2011-12-14 05:15:44 prelink: /usr/sbin/chat: DT_JMPREL tag not adjacent to DT_REL relocations
2011-12-14 05:15:59 prelink: /usr/sbin/pppoe-discovery: DT_JMPREL tag not adjacent to DT_REL relocations
prelink.bin: ../../src/conflict.c:763: prelink_build_conflicts: Assertion `j < ndeps' failed.
Prelink failed with return value 134
== ==
Thank you in advance for any kind of help.


Anleoje 13 years ago

How I check if prelink is working on my machine?


Anleoje 13 years ago

Thank you ;)


m4daredsun 13 years ago

Does anybody know what to choose between prelink and preload?

I am rather fine with preload, but the price to pay in terms of boot time is very high


niebling 13 years ago

All commands worked w/o a fuss. Will report back if noticeable improvement.


ecordero 13 years ago

Thanks for the info! Very helpful!


dagon 13 years ago

Works well. Thanks!


trollboy 13 years ago

@pnin: I think ureadahead is purely for boot speed.

From the Arch Wiki which is a damn good source of Linux info

Ureadahead (Über-readahead) is used to speed up the boot process. It works by reading all the files required during boot and makes pack files for quicker access, then during boot reads these files in advance, thus minimizes the access times for the harddrives. It's intended to replace sreadahead.


pnin 13 years ago

Pardon my noobiness, but something itches me about this tip: is it compatible with the current (July-11) default implementation of ureadahead, or does the later make prelink redundant?

If not, why isn't prelink installed and activated by default, at least in LM LXDE, considering it sees a lot of older hardware, and this could mean a world of difference?


wyrdoak 13 years ago

I've been using both, prelink and preload, seems to be working great.

Desktop comes a little slower on boot, but much better when working on the desktop.


blueXrider 13 years ago

This also works with network files.
Very good Trollboy you get a cookie today and a mint on your pillow.


900i 13 years ago

Well done that man, made my ssd even faster.


JarlArntzen 13 years ago

Hm. Now I'm not sure. I ran prelink and especially OOo *does* seem faster. Starts in 2 sec.

Then I ran [ sudo prelink -ua ] to undo the prelinking again but this results in a long list of shared files which it can not find.

After rebooting I tried starting OOo writer: The first start takes about 4 seconds, all subsequent starts take 2 seconds. I never timed the starts before, but, like I said, it seems a lot faster.

I'm going to test this on a slower computer now.


JarlArntzen 13 years ago

Right. Thanks for a great tip anyway. OpenOffice.org Writer starting up in 2 seconds! Down from 4 :) I need to try this on a slower computer. Thanks!


trollboy 13 years ago

Why is it not included? I don't know.
Are there any drawbacks? I haven't encountered any yet. That doesn't mean I never will ;)

When I do an upgrade, I tend to automatically run the prelink cron script afterwards.


JarlArntzen 13 years ago

How come this is not integrated in all distros by default? What are the drawbacks, caveats and known issues?

Would this fail when I upgrade applications to a new version, which may rely on different dependencies than the previous version?

Seems like an excellent tool anyhow, trying it out now :)


mikefreeman 13 years ago

This is very good! Thank you!


wanda 13 years ago

Libreoffice Writer 4 seconds.


Alexio 13 years ago

Useful tutorial, thank you!