I knew about ccache long time ago, also knew about shm (shared memory) on Linux but I realized that I could:

1. Mount my tmp partition on shm, so all the temporary files would be written on RAM, instead of HDD.

2. Now I set the ccache directory to my tmp directory, this way the ccache files will be written directly to RAM, gaining a better performance than usual.

Now add the following lines to /etc/fstab:

/dev/shm                /tmp              tmpfs           defaults,size=80m,auto 0 0

/dev/shm                /var/tmp          tmpfs           defaults,size=80m,auto 0 0

It is defining 80MB for maximum RAM usage by temporary files, you can define more or less memory, as you wish, of course. The flag “auto” defines that these partitions should be loaded automatically at the boot time.

Now add the folowing line for the /etc/make.conf:

CCACHE_DIR=”/tmp/ccache”

This way, ccache will write to your RAM. Now you can try recompiling your whole system with emerge for a test, you’re gonna realize that your HDD won’t get much stress when compiling the sources, since all the temporary files generated during the compiling process are now written directly to RAM.

I will not get into deeper details about ccache and shm, so I suggest you to read the “references”, if you want to know some more.

References:

#man ccache

http://fscked.org/writings/SHM/shm-1.html#ss1.1

http://en.gentoo-wiki.com/wiki/Ccache

http://blog.flameeyes.eu/2008/06/21/debuking-ccache-myths

http://ccache.samba.org/ (official website)

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=3#doc_chap3

http://www.tuxfiles.org/linuxhelp/fstab.html (fstab tutorial)

About these ads