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 https://wiki.gentoo.org/wiki/CFLAGS. 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!