Gentoo tip: for the love of tmpfs

Ashton Mills16 July 2007, 6:22 AM

When one chooses the Gentoo way patience is most certainly a virtue -- but you can speed it up a bit with this simple and effective tweak. Speed up Gentoo? Read on!


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=1512M,nr_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. 


Post your comment



Comments

RSS feed Email alert

Dan:

Ashton,

I read with much interest your series (In the Mag) on the pitfalls and strengths of Linux and was pleasantly surprised at the depth of options that Linux now shows and its viablity in the marketplace as a 'mainstream' OS, but really, this article only serves to demonstrate its major flaw! As follows:

1. The need to compile in the first place.
2. The need to use the Command Line just to get things moving at an acceptable pace
3. The variability of this technique itself. It doesn't just 'work' in all situations. You need to know when and how to use it.

Now I already have my fireproof jacket on and I expect many rebuffs of my argument and how Linux is better than _everything_ else. But seriously, is this still the state of affairs for Linux to be 'usable?

I am by no means a NooB, I am a SysAdmin for a Windows Network and by no means is it a pleasant experience all the time, but for my end users, and for end users worldwide, why can't it just work without all the forum digging and tweaking.

I understand if you are a techie that may thrill you, (despite my role I have better things to do than muck around with settings that should work!) but along with the screen resolution issues, driver, software and that dreaded DVD problem, I cannot see my boss allowing me to replace our Windows boxes with Linux anytime soon even if it will cost less in the long run.

My users would also have me for breakfast and understandably so...!

Dont get me wrong, I look forward to the day that true competition ensures that ALL OS choices are solid options, but until then, unless the Mum's and Dad's 'get it' we are still in the 'Windows World'!

29 February 2008, 8:31 PM (2 years ago)report abuse Send to a friend reply

g.m:

Dan, I agree with you to a certain extent. I've been using Linux for about a year now, and yes, there are some 'useability' issues yet to be fixed (but it varies with different distros). However, I love the community and philosophy behind many Linux distros, and am prepared to work my way around the few shortcomings that I've encountered with Ubuntu eg codecs (which were very easily resolved by a few extra apps/packages installed).

That said, to Ashton's defence, he is a "techie" type, and the kinds of problems/solutions he is writing about are more likely to occur with "techie" types who like to tinker - - many, maybe most, desktop linux users will never encounter such issues (eg those just using openoffice apps, internet and email - and who install/remove using precompiled packages with a simple gui package manager).

However, such techie articles, while appealing to other advanced users/techies, do have the unfortunate tendency to reinforce old stereotypes of Linux for those unfamiliar with it. That is, some will only see tech problems, tech babble and baffling command line instructions that confirm old ideas of Linux being unfriendly and requiring technical knowledge. But most of those who have actually tried a recent out-of-the-box type desktop distro will know differently - for everyday use, it is usable, and for many, the command line is never needed.

29 February 2008, 8:45 PM (2 years ago)report abuse Send to a friend reply

g.m:

Oh, forgot the most obvious comment.

Ashton is using a distro called Gentoo - a feature of this distro is the compiling of source code to optimise the system and its apps for stability and performance. Some apps for it are precompiled and compiling may be optional.

Most other distros are not like Gentoo. They have extensive online repositories of precompiled binary packages that are installed easily via a GUI (or, optionally, the commandline). The commandline need never be used, and it only requires a few mouse clicks to download and install any of thousands of packages (over 21,000 are available for Ubuntu).

29 February 2008, 8:46 PM (2 years ago)report abuse Send to a friend reply

orvtech:

I dont think that i will gain much of this on my 32Mb of ram NSLU2, will I?

29 February 2008, 8:31 PM (2 years ago)report abuse Send to a friend reply

Jagdpanther:

You can always do this by using the existing tmpfs, /dev/shm. /dev/shm will allocate up to 1/2 of your system RAM for tmpfs and it should already exist. To use it change/add the following three lines to your gentoo /etc/make.conf file:

PORTAGE_TMPFS="/dev/shm"
PORTAGE_TMPDIR="/dev/shm"
BUILD_PREFIX="/dev/shm"




29 February 2008, 8:31 PM (2 years ago)report abuse Send to a friend reply

Brendan:

Lol, such a nice way to steal Ashton's thunder. Although both methods have their advantages, as you said your way only allots up to half, and Ashton's is user configurable.

29 February 2008, 8:46 PM (2 years ago)report abuse Send to a friend reply

anoland:

I used to have this set up on my desktop. Unfortunately, larger packages, notably Xorg use more space than most desktops have. I had to turn it off and never used it again because it was to much hassle.

29 February 2008, 8:31 PM (2 years ago)report abuse Send to a friend reply

anonymous user Anonymous user


Tags