Serious gaming on Linux is a relatively recent thing. As such, most distros won't give you the best performance that your system is capable of, they are instead tuned for 'everyday' use. My own system has quite a few tweaks but unfortunately most of them are difficult to generalise into a user friendly tutorial.
There are however two tweaks you can perform that will make playing games on Linux a smoother experience. They are: adjusting your CPU governor and swapiness. Advanced users will already know this stuff but I've written two simple scripts that should make it a breeze for people new to Linux.
First, some info because I believe you should always know how and why you're modifying your system:CPU governor:
Your CPU voltage is automatically turned up and down depending on how much work the CPU needs to do. This saves on electricity because you don't need the full power of your CPU just to browse the web or write an office document. In everyday situations this is fine because you won't notice it changing. Whilst gaming the amount of work (a.k.a. the 'load') varies in unpredictable ways. This means that by the time the governor realises a complex scene is coming up and that it needs to crank the CPU up to full power, you're already in the middle of that complex scene. This causes visible stuttering in games. By putting the governor into 'performance' mode we are telling it to always run the processor at maximum speed.Swapiness:
This setting has less of an effect but I include it because it gave me an extra frame or two in some games. The 'swap' is an area of your hard drive that the operating system dumps stuff to when it runs out of RAM. This vastly increases the amount of memory available to the OS but your hard drive is a lot
slower than your RAM, so it comes at the cost of performance.
Linux has a preference for how much it will use the swap based on a number between 0 and 100 (a.k.a. the 'swapiness'). Ubuntu ships with a default of 60 which is fine for desktop use where RAM usage is unpredictable. It gives you a nice mix of performance and stability. In games RAM usage is fairly predictable and with most systems having between 4 and 8GB (more than enough for most games) we want to use the swap as little as possible so a setting of 10 is better.Installing The Scripts:
Since this tutorial is aimed at new users I have written it with the assumption that you are using Debian, Mint, Ubuntu or one of its derivatives (Xubuntu, Kubuntu, etc). You will be required to use the terminal for this tutorial but it involves nothing more than copying and pasting the commands I give you.
The first thing you need to do is open a terminal window. This might listed under 'Accessories' or 'System' of your applications menu. Users of Ubuntu derivatives can use the key command CTRL
You need to install cpufrequtils as my script relies on it. Copy and paste this in the terminal:
sudo apt-get install cpufrequtils
Next copy and paste the following into the terminal. It will download the scripts from my dropbox and place them in the correct folder. They are plain text so you can look through them before installing if you wish.
Using the scripts is simple. Before you start a game open a terminal and use the command gameon
. When you finish playing, open a terminal and use the command gameoff
.Uninstalling / Reinstalling / Updating The Scripts:
Paste the following command into the terminal to uninstall the scripts. You must uninstall them before attempting to install a newer version.
sudo rm -rf /usr/local/bin/gameon && sudo rm -rf /usr/local/bin/gameoff && sudo rm -rf /usr/local/bin/gaming_performance_tweaker && sudo -k