Every article tag can be clicked to get a list of all articles in that category. Every article tag also has an RSS feed! You can customize an RSS feed too!
We do often include affiliate links to earn us some pennies. See more here.

GameMode is a new daemon/lib combo for Linux that will allow you to optimize your PC for gaming. It’s not magic, it won’t suddenly make your Linux games suddenly get better performance, but it’s something that can help.

You might have seen a message box pop up with some more recent Linux ports from Feral Interactive, one that tells you that your current CPU governor is not optimised—like this:

When games end up waiting on the GPU, some CPU performance governors may downclock the CPU and then up it again later, which can result in performance problems. GameMode, as it is right now, is to help you with that. Curious about it and wanting to know a little more direct from the developers, Feral agreed to answer some quick questions I had about it:

1) Can you give us a rundown on what exactly GameMode is and why Linux gamers might need it?

“GameMode is a daemon/library combo for Linux, written in C, which allows games to request that a set of optimisations be temporarily applied to the host OS. These optimisations improve the performance of the game.

To apply these optimisations, some of our games require that users manually swap the CPU governor using sudo privileged commands. We've had some feedback from people saying that they'd prefer not to have to do so much setup in order to get the best performance from their game. Further to this, some users voiced concerns about the increased energy usage that might result from leaving the CPU in a higher power usage mode.

By automatically applying these optimisations when the game is running and removing them when it isn't, GameMode saves users the trouble of having to tinker. It also ensures that the CPU is restored to a more efficient state when they've finished playing.”

2) You say it is "intended to be expanded beyond just CPU governor states", what extras did you have in mind?

“A lot of good ideas have been put forward by beta testers, including de-activating tools like f.lux, swapping KWin from OpenGL to xrender, and changing users' chat client status to "Playing X". GameMode is Open Source, so pull requests, or forks with features like these are welcome.”

3) To be clear for our readers, is this something that will ship built-in with Feral games and will users have to do any manual steps to enable it?

“GameMode won't ship with the games; since it's open source, users will need to install it themselves using the steps on GitHub. The tool will only need to be installed once, and will work with all future Linux titles released by Feral.

It will also work with previously released games, provided users adjust their launch options on Steam.”

It’s currently under a “BSD 3-Clause License (Revised)” license and you can find out more on GitHub. It’s certainly going to be interesting to see how this project evolves over time, could end up being something extremely useful. It already made its way to the AUR for Arch users.

Once you've installed it using their instructions, you can then tell any game to use it by doing this command:

LD_PRELOAD=/usr/\$LIB/libgamemodeauto.so ./game

You can also add it as a Steam launch option for each of your games like so:

LD_PRELOAD=$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so %command%

If you wish to know what current CPU governor is in use, you can run this command in terminal:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

I actually had pre-announcement access to it and testing it has given me some good early results. Obviously this will be game and hardware dependent and yes, all tests were done over multiple runs to ensure it wasn't a fluke.

Testing it with F1 2017 for example, gave these FPS results:

That might not look like a big difference, however, behind the FPS results are the frame timings:

  Without Game Mode With Game Mode
Min Frame Time 10.32ms 10.03ms
Average Frame Time 13.31ms 11.88ms
Max Frame Time 19.36ms 16.02ms

As you can see, it has helped to reduce frame timings while increasing the overall framerate, so using GameMode (or manually using performance mode) can have an impact resulting in a smoother game. Using GameMode instead of doing it manually, does have the benefit of your CPU reverting to a more power efficient mode afterwards of course.

Testing Deus Ex: Mankind Divided was a slightly different story, as it always gave a better minimum FPS score when using GameMode, but the average and maximum showed little difference—certainly still worth it though! As for frame timings, the built-in benchmark doesn't give them.

Company of Heroes 2 is similar to Deux Ex with the benchmark mode only giving FPS scores. During my testing, both in the benchmark mode and actually playing it, the difference was noticable when using GameMode—with it being much smoother overall:

Again, to stress, your results will depend on your hardware and it's no different to manually changing your CPU governor to performance—for now (until they do more with it), although it does bring it back down to powersave or ondemand automatically which is nice.

Rise of the Tomb Raider will be the first game from Feral to have support for it integrated, so you won't need to give it any special launch options. However, you still need to install the tool yourself.

It’s great to see Feral Interactive do more open source projects, as they already have their game launcher scripts up on GitHub too.

Article taken from GamingOnLinux.com.
57 Likes
About the author -
author picture
I am the owner of GamingOnLinux. After discovering Linux back in the days of Mandrake in 2003, I constantly checked on the progress of Linux until Ubuntu appeared on the scene and it helped me to really love it. You can reach me easily by emailing GamingOnLinux directly. You can also follow my personal adventures on Bluesky.
See more from me
The comments on this article are closed.
All posts need to follow our rules. For users logged in: please hit the Report Flag icon on any post that breaks the rules or contains illegal / harmful content. Guest readers can email us for any issues.
92 comments
Page: «3/5»
  Go to:

Teodosio Apr 10, 2018
If you are on Debian (as root, it will likely work on Ubuntu as well):
$ apt install cpufrequtils -y

To check available governors and current setting:
$ cpufreq-info

To set the performance governor to all cpu cores, assuming you have 8 logical cores (replace '7' with the correct number minus 1 if different):
$ for i in {0..7}; do cpufreq-set -c $i -g performance; done

Repeat the above with 'powersave' instead of 'performance' or restart the computer to go back to power saving.


EDIT:
On second thought, the following should work just fine on any distribution:
$ echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor


Last edited by Teodosio on 10 April 2018 at 4:03 pm UTC
Nevertheless Apr 10, 2018
./bootstrap.sh
+ meson --prefix=/usr build -Dwith-systemd-user-unit-dir=/etc/systemd/user
The Meson build system
Version: 0.29.0
Source dir: /home/user/gamemode
Build dir: /home/user/gamemode/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: gamemode
Native c compiler: cc (gcc 5.4.0-6ubuntu1)

Meson encountered an error in file meson.build, line 32, column 0:
Unknown function "join_paths".

It refuses to compile for me, followed the instructions to the letter, scratching my head right now, any help would be appreciated.

/home/"user"? Is that correct?
I guess I should have said I edited the output to remove my name.

No problem. It didn't fit the error anyway!
Anders1232 Apr 10, 2018
I hope later versions of this tool come with support for uninstall and/or identify files of older version that are no longer being used to remove them.

Anyway, great job Feral! Already installed!
Mezron Apr 10, 2018
View PC info
  • Supporter
I want to show these guys some support but I do not use Steam. I noticed that some games have a download option with the size showing but when I went to check out I got this message

"Depending on the game purchased, you will receive either a Steam key or a download link after payment is complete"

Are the games with the download feature solid and with no need for Steam?
Shmerl Apr 10, 2018
I want to show these guys some support but I do not use Steam

They were asked multiple times, why they never worked on games that aren't Steam exclusives, but Feral never gave any sensible answer.

Are the games with the download feature solid and with no need for Steam?

I don't think any of the games sold from their site can be used without Steam, but someone can correct me if I'm wrong.


Last edited by Shmerl on 10 April 2018 at 5:07 pm UTC
Eike Apr 10, 2018
View PC info
  • Supporter Plus
Can't the OS detect a game is running and it needs the CPU performing optimally?

Well, what's "a game" from OS's view to beginn with? I'd bet if a process needs all cores all the time, it's easy to crank up, but that's (fortunately) not what's happening with games most of the time. They're only using some cores, sometimes waiting for the next frame time or something... It seems it is behaviour hard to predict.
linuxjacques Apr 10, 2018
A long time ago (> 10 years) I used a daemon which controlled the CPU governors based on a config file.
You could put binary paths and other things in the config file to set which governors were active under
different conditions.

Back then, I needed it just to get no dropped frames when playing DVD rips with mplayer.

I don't know what happened to the tool (don't even recall the name). I think lack of interest let it die.
Nanobang Apr 10, 2018
View PC info
  • Supporter
I have been using cpufreq for this. If you are on ubuntu just install cpufrequtils and indicator-cpufreq then reboot, now you can see a tray icon for cpufreq and you can switch between modes at any time with a single click.

Thank you, thank you, thank you. I installed indicator-cpufreq just now and, wow, what a difference it makes gaming!
Comandante Ñoñardo Apr 10, 2018
They were asked multiple times, why they never worked on games that aren't Steam exclusives, but Feral never gave any sensible answer.


Actually, they gave an answer to sbolokanov:

https://www.gamingonlinux.com/articles/feral-interactive-to-show-off-rise-of-the-tomb-raider-on-linux-next-week-live-on-twitch.11543/comment_id=118863
MacGyver88 Apr 10, 2018
I tested it with Deus Ex MD, Hitman and Total War: Warhammer. Every game had some improvement! 3-10fps min/avg/max
strunkenbold Apr 10, 2018
Microsoft must be like WTF!! They have million dollars (if not billion) of ressource to make a game mode that is slower than normal mode, and a small but well trained team of porter release an open source that actually works as intended!

That's not correct. Feral themselves claimed that Windows thread scheduler is way smarter when it comes to games.
Meant: What feral is doing with their tool does windows out of the box and that for years not just recently with the game mode.
Windows game mode just helps on bloated machines. But it doesn't give a benefit to high end desktops.

That this tool is achieving such big differences in performance is actually just showing how bad the Linux kernel is optimized for games.

I guess feral will show us the first game with superior performance on Linux vs. Windows. Im really excited.
Nevertheless Apr 10, 2018
Good but I would prefer not to install anything. Could we simply run a command before and after playing?

I found a simple suid program on the net, which I just had to change a bit to do the right things.


#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}


and to set it back to powersave:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}
g000h Apr 10, 2018
Built myself a new Ryzen based PC for better gaming, and I already had a script which I was using for changing manually from "powersave / ondemand" to "performance".

BUT... I forgot to install "cpufrequtils" package which the script uses to perform its governor selection. Thanks to this article I've fixed this issue.

Noting that Debian 9 doesn't seem to have the indicator-cpufreq package which some Ubuntu users have mentioned on this thread.
walther von stolzing Apr 10, 2018
...
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}
...

Couldn't you do the same with something like
sudo sh -c 'echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'
Does it have to be compiled C code?
Nevertheless Apr 10, 2018
...
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}
...

Couldn't you do the same with something like
sudo sh -c 'echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'
Does it have to be compiled C code?

Yes you could. But you had to provide your password before you start your game and after you quit it. You can't setuid a bash script, so a binary helps there.
walther von stolzing Apr 10, 2018
You can't setuid a bash script, so a binary helps there.

I wasn't aware of that; that's good to know, thanks.
Ketil Apr 10, 2018
You can setup sudo to work without password for certain commands even if they are written in bash. I prefer that over setuid.
## In sudoers, edited with visudo
myuser ALL = (ALL) NOPASSWD: /usr/local/bin/mysudocommand



Last edited by Ketil on 10 April 2018 at 8:22 pm UTC
walther von stolzing Apr 10, 2018
You can setup sudo to work without password for certain commands even if they are written in bash. I prefer that over setuid.
## In sudoers, edited with visudo
myuser ALL = (ALL) NOPASSWD: /usr/local/bin/mysudocommand

Yeah I was about to ask whether you could define a Cmnd_Alias for a shell script in sudoers to then add a NOPASSWD exception; but this approach seems to be even simpler. Does it have to come at the end of the sudoers file though?

... sorry about the off-topic spam, though.


Last edited by walther von stolzing on 10 April 2018 at 8:27 pm UTC
Sputnik_tr_02 Apr 10, 2018
I have been using cpufreq for this. If you are on ubuntu just install cpufrequtils and indicator-cpufreq then reboot, now you can see a tray icon for cpufreq and you can switch between modes at any time with a single click.

Thank you, thank you, thank you. I installed indicator-cpufreq just now and, wow, what a difference it makes gaming!
You're welcome. You may also wanna check Ananicy
That service allows you to control process priority of any processes. You can add any process to the config files (.rules) and set a profile (types) for it and it automatically sets the priority when the process is executed, it has premade profiles for games and such. Every bit helps i guess.
Shmerl Apr 10, 2018
They were asked multiple times, why they never worked on games that aren't Steam exclusives, but Feral never gave any sensible answer.


Actually, they gave an answer to sbolokanov:

https://www.gamingonlinux.com/articles/feral-interactive-to-show-off-rise-of-the-tomb-raider-on-linux-next-week-live-on-twitch.11543/comment_id=118863

Very interesting, and from it, it sounds like they can decide where to release, unlike many said before? Then why not on GOG?
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
The comments on this article are closed.