Wednesday, November 17, 2010

Using readahead to speed up disk loading times of any application

Here's a way to get a list of files read by any application, so you can use readahead to preload those files optimally from disk (conventional spinning hard drives, this probably doesn't do so much for SSDs):


CMD=firefox
strace -fe open $CMD 2>&1 | grep open | sed 's/.*open("\(.*\)".*/\1/' > $CMD.preload

# you can sift through that $CMD.preload file to look for things that don't belong

readahead $CMD.preload # preloads all those files into cache

time $CMD # should now start quite a bit faster, without much disk activity

## to clear disk cache as root (useful for testing / benchmarking)
echo 3 > /proc/sys/vm/drop_caches

If it works, you might want to append the contents of the .preload files for your commonly-used apps to /etc/readahead.d/default.later , so they are automatically loaded on startup (RAM size permitting)


No comments:

Post a Comment