Performance on Linux. Just how far *can* we go?

Performance on Linux. Just how far *can* we go?

As the title suggests, Linux and performance in the same sentence makes for an interesting topic of discussion. Everyone knows there is a multitude of options available to us. In this article, I’m going to attempt to cover a few of them.

The first thing we need to work out is are we using a source based distribution (eg. Gentoo/Funtoo) or a Binary based distribution (eg. Fedora/Debian/Ubuntu). Each of these examples carry some variables that the other ones don’t. Source based distributions allow you to modify the compiler options to optimize the code at build time, whereas the binary based distributions don’t allow us to do this (unless I’m proven wrong).

Starting with the source based distributions, we can find the best CFLAGS to run by a quick trip to the following link This will give us the safe CFLAGS to use for our processor, which is what the initial focus of this article is. Later articles will focus on more in-depth ways we can get a bit more speed out of our beloved Linux installation.

Once we have the safe CFLAGS we want to use, the following excerpt from the afore mentioned link explains what we need to know:

The CFLAGS and CXXFLAGS are environment variables whose content is passed on to each invocation of cc (the C compiler, usually gcc) or C++ (the C++ compiler, usually g++), respectively, during compile and build phases of software. Within Gentoo, these variables are set in /etc/portage/make.conf so that each compile job invoked by the package manager uses them.

This does mean we will also need to perform an update and world rebuild with the new flags. Let’s see if I can remember the options:

emerge --sync && emerge -eavuD world

This instructs Gentoo to perform a sync, then to recompile the world with new build CFLAGS.

I’d leave this alone for a while, because it could take a bit. So we can move along to the next thing we want to look at while working along this path.

HDParm, our beloved hard disk tuning package. The first thing we need to find with this, is what the settings our drive is currently using. We can do this by performing the following commands:

hdparm -i /dev/<sda/hda> & also hdparm -I /dev/<sda/hda>

These commands will talk to the drive and relay their current settings, showing us how they are configured. From here, it’s a case of messing with readahead cache (-a), write cache (-W), which are two of the main ones you need to look at, if aiming to just do a bit of “tweaking”.

Of course as you can gather, this is just the tip of the iceberg. There is many many more options we can discover. Part of the thing you will need to consider while doing all of this is, is the effort you are putting in worth the result you will get? All these options/tweaks/changes will only get us so far. If your hardware is ancient, just remember the law of diminishing returns.

Full-system update to latest code is always another good starting point. You will be surprised just how much performance gains you can obtain from just performing a full system update.

This guide will more than likely end up being a multi-part, as there is far too much to cover in just one article for someone to read (maybe the hardcore fans!).

Don’t forget my motto, if it ain’t broke, you ain’t tweaked it right! Peace out!

  • Daniel Sandman

    And then you have the semi source based distros like Arch and Sabayon. Where the core part is binary and you build only the packages you want to build. In a way getting a little bit of both worlds. You don’t have to build everything but still get the performance from compiling yourself.

  • Василий Алексеенко
  • Василий Алексеенко
  • JFM

    There are two kiçnds of optimization articles: those who benchmark the effects and the amateurish, useless ones

  • JFM

    Sorry for being so harsh but dozens of articles of “I have not the slightest idea if it will make your computer 50% faster or if it will make it 1 send in a million years but I advise you to waste hours of your valuable time recompiling the kernel” have exhausted my patience about articles about optimization with no benchmarks and no hint if you will ever recover your investment. Compound it that these articles scare away Windows users out of Linux and that 99% of them give zero information beyond “remove what you don’t need” (Wow! I needed and überhacker to tell me not to remove what I need”) and specifically what NOT to do with the UI config part or you will end with a headless or keyboard-less machine.

    At least your article had some real content.

  • JFM

    Should have read “make your computer 50% faster or if it will make it 1 second in a million years faster”

  • Puc

    Completely agree with you there mate. This article brings nothing. Zero.

  • Caleb Cushing

    Only some software can really take advantage of different flags and cpu optimizations. mencoder is one such thing. Arch Linux is a binary distribution which allows you to easily rebuild packages using PKGBUILD.

  • Xavi

    You should be careful with hdparm, In the past it caused data corruption to my filesystems, forcing me to reinstall the whole system. It is not worth the risk.

  • jack

    Goodness gracious! This is a great article… NOT!!!