Gentoo tip: for the love of tmpfs

I should probably feel ashamed — I’ve been using Gentoo since *counts on fingers*… almost since it began. Back when Daniel Robbins was leading the charge and it quickly became the world’s most popular source distribution.

Because that’s the other side of the double-edged source-distro sword: optimised performance complete configurability — and anywhere from minutes to hours for any application you install. Now granted I have Gentoo on a RAID 0 stripe but oh my gosh how did I ever miss this simple tweak?

The following line added to /etc/fstab will speed up your compile times reduce disk thrashing and make you attractive to the opposite sex:

none /var/tmp/portage tmpfs size=1512Mnr_inodes=1M 0 0

Just make sure you set ‘size=’ to a value less than your total RAM. Here I’m using 1.5G for my 2G system.

What does it do? It knocks out the slowest component of your system your hard drive from the compiling process mapping /var/tmp/portage — where Portage stores all the temporary files during compilation — to a tmpfs in memory. And tmpfs bless it is dynamic and only uses as much as it needs — so the 1.5G setting I use is only its maximum allowable size. If nothing is being compiled no memory is used.

The speedup is nice but dependent on what’s being compiled and the speed of your drive (less benefit for 10k RPM drive users for example). Only caveat: some large compiles may need more space (Open Office for example needs at least 3G) and when it does the kernel will page tmpfs out to swap slowing the whole process down. Only a handful of applications may need this in the hundreds you compile however. Still if you have less than 1G you don’t want to be allocating most of that and you may need to disable it (just umount /var/tmp/portage) for the super-large packages.

tmpfs has many other uses but this one never occurred to me until I read it in passing in a forum post. Simple and effective all the best tweaks are.

Edit: There’s a wiki entry here for it.