Steam for Linux

Steam for Linux

Tutorial: Tweak your system for better gaming performance
EDIT: This script is old but it mostly still works. The swapiness and CPU governor tweaks still work as do most of the compositor tweaks. However the Unity compositor tweak should never be enabled. It was written for a much older version of Unity and will cause you problems if you enable it.


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 frequency 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+ALT+T.

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.

cd /usr/local/bin && sudo wget http://dl.dropbox.com/s/wd2x7ew5sm8jj0f/gameon && sudo wget http://dl.dropbox.com/s/14phvgbz42lu7a9/gameoff && sudo wget http://dl.dropbox.com/s/lgpsjmgloqgltg5/gaming_performance_tweaker && sudo chmod +x /usr/local/bin/gameon && sudo chmod +x /usr/local/bin/gameoff && sudo chmod +x /usr/local/bin/gaming_performance_tweaker && sudo -k

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
Отредактировано Fibbs; 29 мая. 2016 г. в 13:24
< >
Сообщения 115 из 53
This is a great guide, but I recommend always setting the swappiness at 10; at this time and age, swappiness lacks much a purpose. If you have more than 8 GB RAM, I recommend no more than 2 GB of swap. Swap was originally used when computers had very little RAM. If you have 12 GB+ RAM, you don't need swap at all.
This is a very nice tutorial! :D
Beginners will love it.

Although there are more things to improve performance, I will give this a 10/10 for it's contents and ease of use.

Автор сообщения: RAVEN MCCCXXXVII
This is a great guide, but I recommend always setting the swappiness at 10; at this time and age, swappiness lacks much a purpose. If you have more than 8 GB RAM, I recommend no more than 2 GB of swap. Swap was originally used when computers had very little RAM. If you have 12 GB+ RAM, you don't need swap at all.
Except when memory dumps occur, which is quite easy in Linux :P
Отредактировано Toquita; 16 мар. 2014 г. в 18:00
You may want to add entries for installing and using "sysv-rc-conf", which lets you disable startup services. There are some quite heavy ones which don't concern most people. There's only a few in Ubuntu/Debian to sift through, a simple description of what it is for will do.

Additionally adding a ramdisk for the temp files by adding:
"tmpfs /tmp tmpfs nodev,nosuid,size=512M 0 0" to /etc/fstab.

Although only if you have ram to spare, I use a temp size of 1024mb.
Oh, and another thing you can do with fstab.

You can remove the file and directory access time, basically by default whenever the file is accessed, the filesystem will update the time it was last accessed.

Say I have this in my fstab:
On the line of your filesystem, replace:
errors=remount-ro
with
errors=remount-ro,noatime,nodiratime
Then it's no longer a Newbie's Tutorial :D

BTW a 512 MB tmp seems a little small. I use at least 12 GB: 8 GB will guarantee I have space to copy a Dual-Layer DVD, and the rest is free.
Cheers for the replies guys. I wrote this because there are a lot of people coming to these forums complaining that they don't get the same performance as in Windows. I've tried to stay away from making a general 'improve your Linux performance' guide because new users don't really know enough about the changes they're making. When they learn more they can make their own permanent modifications. My aim here is to simply give them a 'turbo' button that anyone can use whilst gaming which will return their computer to its default state afterwards.

Автор сообщения: Zom zom! :D
This is a great guide, but I recommend always setting the swappiness at 10; at this time and age, swappiness lacks much a purpose. If you have more than 8 GB RAM, I recommend no more than 2 GB of swap. Swap was originally used when computers had very little RAM. If you have 12 GB+ RAM, you don't need swap at all.

Having some swap is always advisable to avoid kernel panics if you run out of memory. There are some edge cases where having a low swapiness value can actually result in lower performance. Until a user knows more about what they're doing I want the change to remain reversible.

Offtopic: Does anybody actually use 12GB of RAM? I don't know of anybody who uses a triple channel motherboard in their gaming / home system.


Автор сообщения: Fluffy
You may want to add entries for installing and using "sysv-rc-conf", which lets you disable startup services. There are some quite heavy ones which don't concern most people. There's only a few in Ubuntu/Debian to sift through, a simple description of what it is for will do.

Additionally adding a ramdisk for the temp files by adding:
"tmpfs /tmp tmpfs nodev,nosuid,size=512M 0 0" to /etc/fstab.

Although only if you have ram to spare, I use a temp size of 1024mb.

Disabling startup services probably falls into a more general 'Linux tuning guide'. I will look into some that can be disabled whilst gaming and restarted afterwards. It is complicated by the fact that they vary between distros however.

I'm not sure how much of a performance boost using a ramdisk will give. Games already cache their assets in the RAM. The lower swapiness setting is used to try and make them stay there.

Автор сообщения: Fluffy
Oh, and another thing you can do with fstab.

You can remove the file and directory access time, basically by default whenever the file is accessed, the filesystem will update the time it was last accessed.

Say I have this in my fstab:
On the line of your filesystem, replace:
errors=remount-ro
with
errors=remount-ro,noatime,nodiratime

I'm not sure how much of a performance boost this will give but tbh it falls outside the idea of a gaming 'turbo button'. It also has repercussions for everyday use of the computer.

I'd like to incorporate any general tweaks that you guys can suggest though. Anything to make things easier for new users.

I've managed to get a few extra frames by completely killing the desktop compositor whilst gaming. Most compositors use a 'do not redirect fullscreen windows' option to prevent games from being composited. However it's not always accurate and you still have your composited desktop taking up video memory. I've found by killing the compositor completely I can free up about 40MB extra video memory when using a 1080p desktop.

I can do this on my system because I use a compositor called compton which runs as a separate process from the window manager. This means I simply include 'killall compton' in the gameon script and 'compton -b' in the gameoff script to stop and start the compositor. I'm currently looking into ways to do this for all the major desktops and hope to include it in the scripts.
Отредактировано Fibbs; 17 мар. 2014 г. в 15:07
Just a note you might wanna change linux default I/O from CFQ to Deadline for platter based HDD's Noop for ssd's It depends tho largly on what your doing with the drive..
Автор сообщения: Linux Junior s2 Camila
Then it's no longer a Newbie's Tutorial :D

BTW a 512 MB tmp seems a little small. I use at least 12 GB: 8 GB will guarantee I have space to copy a Dual-Layer DVD, and the rest is free.

DVD? I've thought we are in 2014 :P
http://ubuntuforums.org/showthread.php?t=1889034

Here's a nice thread for KDE tweakers. I personally am not impressed by KDE because I think the user experience offered therefrom is lacking and outdated. Just saying.
Uploaded some new versions of the scripts.

Changes:
- Added clean dependency check.
- Number of cores adjusted is based on the return of nproc rather than an arbitrary number.
- Restructured the scripts so they're easier to extend.

I'm working on some further things I can add into the scripts (particularly compositor / desktop effect stuff) but they're not ready for general use yet.

Cheers for the KDE link, I'll have a read through it whilst eating dinner :)
Автор сообщения: Zom zom! :D
.
Zom zom huh? :D LOOL
Uploaded some new versions of the scripts (v1.4.5). I'm actually having quite a bit of fun tinkering with these things. I might have to sign up to github or something though because I don't know how long the forum mods are going to tolerate me replying to my own thread with what are essentially change logs.

Changes:

- Added a config file and associated functionality.

- Added in experimental support for disabling and re-enabling compositing. Currently supported compositors / window managers are: Compton, XFCE, KDE, Gnome 2 (metacity) and LXDE (xcompmgr).

- Restructured the script so I only have to maintain one file instead of two.

The config file is located in your home folder and named '.gaming_performance_tweaker'. It is generated the first time you use the 'gameon' command. The default values should still be 'fool proof' for new users. The config file is mostly for the benefit of more advanced users as it lets them specify their own values for each tweak (like swapiness for example,) or bypass certain tweaks altogether.

The tweak for toggling compositing is still experimental. It is disabled by default but can be enabled in the config file. The Compton and XFCE options have been heavily tested and work. The others will receive more testing in a VM when I get time tomorrow. I'm fairly sure KDE should work, Gnome 2 and LXDE less so.

Unity and Gnome 3 are giving me a bit of a headache. The only way I've found so far to disable compositing in them is to fallback to different window managers which is far from ideal.

If you want to try them out and give feedback I'd really appreciate it.
Отредактировано Fibbs; 19 мар. 2014 г. в 21:29
Unity can be made faster not by disabling compiz, but by simply disabling certain effects/animations and so forth. I personally think that as of Ubuntu 14.04 Unity is a lot more intuitive and responsive.
Автор сообщения: Fibbles
If you want to try them out and give feedback I'd really appreciate it.
I definitely got some things out of it. Before this thread I had all my (8) cores set to performance governor 100% of the time.
I didn't realize it was so simple to switch back to ondemand while not gaming.
I don't have use for the compositing feature but I'm sure there are those who do. I'll keep monitoring the changes though. Thanks for what you've done so far.

Автор сообщения: Fibbles
I don't know how long the forum mods are going to tolerate me replying to my own thread with what are essentially change logs.
A forum feature to be able to reply without bumping the thread would be amazing. like sage
But I guess that could also lead to some trouble
Отредактировано slrp; 19 мар. 2014 г. в 23:30
New version of the script uploaded (v1.5.0)

Changes:

- Added an interactive setup for the config file. Only happens the first time you run the script or if you delete the config file.

- Added ability to exit the script after setting up the config file. Useful if you want to manually edit the config before running any tweaks.

- Added and tested support for disabling and re-enabling compositing in a bunch of desktop environments. Supported compositors / window managers are: Compton, XFCE, KDE, Gnome 2, Gnome 3*, LXDE (or anything else that uses xcompmgr), Cinnamon*, MATE, Unity 3D*.

*Can't actually toggle compositing in Gnome 3, Cinnamon or Unity so the script just toggles desktop effects instead.

- Added option to modprobe governor modules. Useful if cpufrequtils keeps giving errors. Can only be enabled via the config file.

- Added support for clearing the cache before starting a game. Only useful in limited situations so it's disabled by default and can only be enabled via the config file.

- Added an option in the config file to disable the 'sudo -k' at the end of the script. Useful if you want to call my script from one of your own.

I can't really think of anything else that needs to be added. If anyone has any useful tweaks I'll add them in. If you find any bugs please let me know.

I'll rewrite the first post at some point to better reflect what the script does now. The installation instructions etc are still correct.
< >
Сообщения 115 из 53
Показывать на странице: 1530 50

Дата создания: 16 мар. 2014 г. в 16:29
Сообщений: 53