kokoko3k / gopreload

Preloads files needed for given programs.
43 stars 7 forks source link

GOPreload Readme

Description: Got tired of the way the kernel decides what to keep cached and what not, especially after watching a DVD or copying large files, I decided to write two simple scripts which keep the applications I use most in the system cache by mmapping and mlocking them in memory.

Requirements: fmlock (sourcecode included thanks to datenwolf) strace readlink basename dirname

Installation:

Usage and example: First of all, you must think on a few applications which you REALLY need to be very responsive on starting. Take firefox as an example:

--
I will use then 'Prepare.sh' that way:
/usr/share/gopreload/bin/Prepare.sh firefox
(wait for Firefox to fully load and press ENTER in the shell)

Now Prepare.sh has created a new file called firefox.YourUID.openfiles.txt
in the /usr/share/gopreload/enabled/ folder.
The generated filename includes an estimation of the MB wich will stay
resident in ram.
It contains the list of files which firefox needs to start-up, the
idea is to keep them in ram so that next time firefox will start,
it will not read them from disk and will start-up much, much faster.

You can reiterate Prepare.sh as much as you like, think of konqueror,
nautilus, kwrite, gedit and so on, but don't do too much, because
your memory is limited.

***NOTICE:***
As soon as you update firefox or its needed libraries, you will
need to (re)Prepare it again!
To re-prepare your programs in an automatic/batch way,
(eg: after system upgrades), you can use:
/usr/share/gopreload/bin/batch_refresh.sh
--

--
Non systemd users:
    Now that you 'prepared' your programs, you need to use 'StartPreload.sh',
    and you need root privileges.
    sudo /usr/share/gopreload/bin/StartPreload.sh
systemd users:
    systemctl start gopreload

Just sit and wait for StartPreload.sh to preload the file lists 
you created with Prepare.sh, next time (and forever) you will launch 
the programs you choose, you will notice a nice speed boost,
even if you're short of memory.
StartPreload.sh can be launched with debug parameter:
./StartPreload.sh debug
...to see some interesting things.
--

You may have noticed that there are two folders under GOPreload:
* /usr/share/gopreload/enabled/ meaning should now be clear
* /usr/share/gopreload/disabled/ is empty, you can use it to move filelists
'on the fly' from enabled/ to disabled/ folder.
StartPreload.sh will notice the changes and will react accordingly.

Configuration Variables: Prepare.sh:

Suggestions:

Some Benchmarks; Start Application Times

Program WithPreload WithoutPreload
oowriter 0m3.502s 0m11.768s
thunderbird 0m3.704s 0m12.675s
firefox 0m5.038s 0m16.160s
winecfg 0m2.559s 0m5.032s
kwrite 0m1.166s 0m3.045s