Various Optimization Topics for Linux Users

Everyone wants software to get faster. Specifically, everyone wants the software on their machine to be faster so they can do things quickly and efficiently. On Linux, there are plenty of ways to to improve your experience if you’re willing to do the work.

I have had the pleasure of using Linux for many years now, and I’ve collected some tips from around the ‘Net and made some observations of my own on speeding up my system. Now I’ll pass on some of this information here, albeit a bit scrambled. Hopefully someone will find it of some sort of use (that’s the plan, right?).

Compiling Source vs. Downloading Binaries

When dealing in Linux-based operating systems, you have the option either to download software in binary form (pre-compiled, the way most software is distributed on Windows), or download the source code and compile it yourself. What difference is there between these two options, though?

Let’s start with a brief overview of CPU architectures. These days, 64-bit processors are becoming more popular. 64-bit CPUs generally have support for 64-bit instruction sets and extensions. For example, you might see the term “x86″ for a 32-bit processor or operating system, while the term “x86-64″ might appear if you’re using a 64-bit processor and operating system. This term specifies the architecture upon which your CPU is based. As you might guess, x86-64 implies an x86 architecture with 64-bit extensions.

Most modern CPUs support more than the traditional x86 instruction set, however. For example, many of today’s CPUs support the SSE series of instruction sets. These instruction sets include routines designed for performing many specialized operations. For example, the original SSE instruction set includes assembly routines specialized for floating point math operations. As a result, CPUs that support SSE can perform functions involving float point numbers more efficiently.

When you download a binary to your computer, it’s been compiled and built elsewhere on another person’s computer. In order to ensure compatibility across a wide range of machines, however, developers will target only a general architecture when compiling these binaries for distribution (that is, they will target the x86-64 architecture but maybe not a specific instruction set such as SSE). So really, the binary software you download is not optimized for your machine, probably resulting in a slower experience. (It’s got maximum compatibility at the cost of maximum performance.)

The importance of taking these extra CPU features into consideration when compiling software can mean the difference between a slow program and a speedy program. A program targeted at a general population of CPUs might take tons of instructions in order to perform a function, while a program that is compiled with support for a specific instruction set might be able to perform that function with less instructions, generally resulting in a faster execution time.

I won’t go into the details of compiling software specific to your hardware here, as I believe that would take an article all on its own. If you are able to install and configure Linux, however, you should be able to easily figure out how to compile software yourself with the assistance of Google and Linux’s supportive community.

Custom Kernels

For the more advanced power users, you can try to compile your own kernel. In that case, you’ll want to include the BFS patch. This patch will tune the way the kernel schedules processes, making things appear smoother for desktop users. In addition, you should generally configure the kernel to optimize for speed, rather than size (-O2 rather than -Os). There are some instances where optimizing for size is actually faster, however, it depends on the scenario. This is obviously not the place for me to explain the entire process of compiling a kernel yourself, so I would recommend you check out documentation specific to your distribution.

Reducing Swap Usage

If you’re hip on the computer lingo, you’ve probably heard the term “swap” thrown around by now. When your computer runs out of RAM to store temporary data, but it still needs memory to allocate to programs, it will usually resort to using swap space, which is space on your hard drive then set aside as memory for programs.

Swap space has a nasty side, though. The typical hard drive today is awfully slow — many magnitudes slower than RAM, and even more magnitudes slower than the caches and registers you would find in the CPU. As a result, if your computer resorts to using swap space, you will find that the program you’re using (or even the computer as a whole) probably lags terribly.

Luckily, nowadays, memory is cheap. We’ve gotten to a point where you can get many gigabytes of RAM for less than $100. I just picked up 16 GB for $60 ($30 after I applied my Newegg gift certificate). That’s simply mind-blowing considering 16 GB was a mere pipe dream not too long ago. From my experience, I would say that you no longer need swap space once you have 8 GB of RAM. In that case, you can tell Linux to stop swapping data through the following command in the terminal:

echo "vm.swappiness=10" > /etc/sysctl.d/20-swappiness.conf

This should suffice for most Linux distributions. If you’re unsure, Google around to see if there are specific instructions for your distribution.

So there are some of my tips for speeding up your Linux installation. Hopefully you are adventurous enough to do a bit more research on these topics and attempt to try them out yourself. Using Linux is a great learning experience, but you’ll only learn if you try.

Article Written by

  • http://twitter.com/vyperx1 VyperX

    Thanks, this contains part of the information I was looking for!

  • mrgaribaldi2263

    The Gentoo philosophy explained.

  • Anonymous

    The Gentoo philosophy explained.

  • Robert Naramore

    I use Linux Mint x86-32 on a Pentium4 machine with 2GB of DDR2 Ram and an amazingly small 8GB hard drive. It browses the web amazingly well. I have the base install along with Google Chrome added. It would run a bit faster when I put a larger hard disk in it. Do not get me wrong it runs fast but it would be faster with  more room for a swap file that is larger than 256MB.

    • https://launchpad.net/~korben-lopbox Papageorgiou Dimitrios

      my friend as the author says.. if u add ram to your machine more than 8Gb you will not need swap. For example, i have 3Gb of ram on 400Mhz DDR on 128bit dualchannel support and i have set 1Gb of swap for my machine.  My machine uses eventually the swap when i have already opened a virtualbox, chrome, music, too many flash pages all together.

  • Ian singleton

    Linux is great for older machines that have less horse power than newer ones, I have used Unbuntu on a Netbook and it runs very well booting very quickly I could quite happily have Unbuntu on a low power laptop or netbook.

  • Gabriel Paiva

    other great tip if you are running a more “complete” distro is also check what are the services starting on your machine on boot via the scripts in your runlevel (type runlevel with root on the terminal) and you will se a number with is the number of the “mode” linux is booting in,than go to /etc/rcx.d where the x is the number you see and see all the scripts pointing to daemons,like ssh,samba,cups etc and you can remove the ones you dont use like for exemple you will not need cups if you dont have a printer or samba if you dont want to share nothing on a Windows network,etc and also do “specific” checks on you desktop enviroment checking the scripts starting at your session of gnome or kde can also really speed up your boot time if you are on a older machine. =)

  • Prajyot Walali

    That was really helpful. Thanks a lot.