Don't want to see articles from a certain category? When logged in, go to your User Settings and adjust your feed in the Content Preferences section where you can block tags!
We do often include affiliate links to earn us some pennies. See more here.

You will want to force your CPU into high performance mode for Vulkan games on Linux

By -
Last updated: 10 Oct 2019 at 7:04 pm UTC

There's an interesting issue with certain Linux CPU governors that will actually bring down performance in Vulkan games. You might not need this, depending on what CPU governor you have installed.

You might end up seeing jerking or micro-stutter, far more than you would in OpenGL games. The issue is that when using OpenGL in games, you're generally taxing a single core of your CPU due to less multi-threading. With Vulkan spreading the load more, your CPU isn't being used so much.

The Linux CPU governor takes that as an opportunity to bring down your CPU performance, as right now it's not the smartest bulb in the tanning bed.

Here's what a Croteam developer said about the issue:

QuotePowersave governor is an awful choice for playing games. It may quite be the case that it's not happening for OpenGL especially because GL runs slower.
When the game is running fast enough that CPU has to wait on the GPU, the governor sees that as an opportunity to downclock the CPU, or put cores to sleep. The jerking is a result of the CPU throttling up and down very quickly.
In general, CPU governors on Linux are much, much dumber than the Windows one. (It seems that Windows overrides the throttling for all 3D apps, or similar.)
That's why we have this warning in the log. Switch over to Performance governor, at least while playing.

So a tip for now when playing Vulkan games on Linux: Set your CPU to high performance mode, you can do it like so in terminal ("performance" is just an example, see more here):
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
A higher performance mode will generally result in higher power consumption too.

Then to set it back to normal. You don't need to use "powersave" see more options here, as it's just an example. According to the Arch Wiki you likely want "ondemand" for AMD:
echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

You can find out what performance mode you're in right now by running this in terminal:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
My default on the Intel i7 5960x is powersave, for example.

Hopefully this issue will be fixed as more games come over to Vulkan. It would be nice if developers didn't need to code around issues like this on Linux.

Article taken from GamingOnLinux.com.
Tags: Editorial, HOWTO
17 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.
75 comments Subscribe
Page: 1/4»
  Go to:

buenaventura 23 Mar 2017
Hmm, does this setting the CPU governor to performance impact games otherwise you think (like, with OpenGL on a weak CPU?).

I have a AMD quadcore A8-6410 ("up to 2.4 ghz) on my laptop, and I struggle to play Shadow Tactics (and other unity games) on lowest settings, sometimes I think my CPU is at fault as much as my GPU. top reports around 250% CPU usage (which means 2.5 cores used I guess) for Shadow Tactics. Is it possible to increase that usage, you think?
Liam Dawe 23 Mar 2017
Hmm, does this setting the CPU governor to performance impact games otherwise you think (like, with OpenGL on a weak CPU?).
It's not magic, it doesn't suddenly make a weak CPU any better. It's only an issue if when playing games your CPU isn't being set into high performance mode. With OpenGL games it likely always is, since they are generally heavy on the CPU.
Eike 23 Mar 2017
View PC info
  • Supporter Plus
Hmm, does this setting the CPU governor to performance impact games otherwise you think (like, with OpenGL on a weak CPU?).

I have a AMD quadcore A8-6410 ("up to 2.4 ghz) on my laptop, and I struggle to play Shadow Tactics (and other unity games) on lowest settings, sometimes I think my CPU is at fault as much as my GPU. top reports around 250% CPU usage (which means 2.5 cores used I guess) for Shadow Tactics. Is it possible to increase that usage, you think?

It's worth a try. I had to do it - strange enough - for Limbo to work in the correct speed. :)
Aro 23 Mar 2017
Will try this later today on dota and serious Sam with a strong cpu (6600k) and see how it affects performance.
dubigrasu 23 Mar 2017
I always set the governor in performance mode when I'm playing, this is not the only game with such issues.
While my current Intel CPU is not that affected, the former AMD one FX 8370 was really bad at this, the framerate was all over the place on ondemand mode and stuttering all the time.
poisond 23 Mar 2017
@liamdawe
Uh, powersave isn't the default governor, at least it shouldn't be. powersave will run your CPU at the minimum freq.
You want ondemand.


https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt


Last edited by poisond on 23 Mar 2017 at 10:32 am UTC
Keyrock 23 Mar 2017
Thanks for the heads up, Liam. I made two files, called gov_perf and gov_psav and copied the short scripts into them, then made them executable and copied them to usr/bin. That way I can issue the commands from any directory with a single word typed. I'm sure I could add gov_perf to launcher scripts of games so that the process is auto-magic. Now to figure out a way to make games trigger gov_psav upon exit... ![](http://www.thethinkingatheist.com/forum/images/smilies/extra/consider.gif)


Last edited by Keyrock on 23 Mar 2017 at 10:35 am UTC
dubigrasu 23 Mar 2017
@liamdawe
Uh, powersave isn't the default governor, at least it shouldn't be. powersave will run your CPU at the minimum freq.
You want ondemand.


https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt
It is for Intel (with intel_pstate), ondemand is the default for AMD.
Keyrock 23 Mar 2017
@liamdawe
Uh, powersave isn't the default governor, at least it shouldn't be. powersave will run your CPU at the minimum freq.
You want ondemand.


https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt
Not exactly. AMD chips use ondemand, as well as some really old Intel chips. Newer Intel chips use powersave as the intel_pstate driver takes care of the scaling.

Edit: Ninja'd


Last edited by Keyrock on 23 Mar 2017 at 10:40 am UTC
Liam Dawe 23 Mar 2017
@liamdawe
Uh, powersave isn't the default governor, at least it shouldn't be. powersave will run your CPU at the minimum freq.
You want ondemand.


https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt
Well, to be sure I've updated the text to mention people to use either, thanks for the extra tip.
Eike 23 Mar 2017
View PC info
  • Supporter Plus
@liamdawe
Uh, powersave isn't the default governor, at least it shouldn't be. powersave will run your CPU at the minimum freq.
You want ondemand.


https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt

I'm not 100% sure, but AFAIK, I found powersave and performance the only states implemented for my i3570K when I looked.

*edit*
http://www.phoronix.com/scan.php?page=news_item&px=MTM3NDQ
The reality is that such control algorithms are CPU specific, the notion of a generic "for all cpus" governors is just outright flawed; hardware behavior is key to the algorithm in the first place....


Last edited by Eike on 23 Mar 2017 at 10:45 am UTC
MayeulC 23 Mar 2017
Uh? "powersave" shouldn't be the default. I think "interactive" is. It provides some sane balance between power usage and performance.

I would generally advise "powersave" only when battery life is a problem, to maximize its capacity (and bear with a bit of stuttering/other), maybe lower the settings a bit as well to minimize the power draw.

Now, on desktop, I think that "interactive" is the default, which is a good one IMO. I would be curious to see some comparison with "performance" on Vulkan, but I don't expect it to change the result by more than 0.5-1%, and you might have much higher idle power draw. I personally never bother to change it.

You might also want to avoid "conservative", which might have lower performance than "powersave".

That's if for the basic performance governors, but I want to point out that, while performance governors and schedulers might seem "dumb" (probably because they are well-documented, and generally don't try the one-size-fits-all approach), they are well-proven and battle tested, from small embedded devices, to Android phones, to supercomputers.

There is also more to scheduling than performance governors, and the schedulers can have a role to play as well, but I don't think that gaming is the most complex scenario to handle, so this should make little difference, except for special cases.

EDIT: Ninja'd by a bunch of people :P Also, it seems that I am confusing "ondemand" and "interactive". I can't check ATM that "interactive" is what I am using, but IIRC, it should be a bit more aggressive on frequencies than "ondemand". Not that much difference, though. And yeah, "ondemand" might be the default.


Last edited by MayeulC on 23 Mar 2017 at 10:49 am UTC
Keyrock 23 Mar 2017
Uh? "powersave" shouldn't be the default. I think "interactive" is. It provides some sane balance between power usage and performance.

I would generally advise "powersave" only when battery life is a problem, to maximize its capacity (and bear with a bit of stuttering/other), maybe lower the settings a bit as well to minimize the power draw.

Now, on desktop, I think that "interactive" is the default, which is a good one IMO. I would be curious to see some comparison with "performance" on Vulkan, but I don't expect it to change the result by more than 0.5-1%, and you might have much higher idle power draw. I personally never bother to change it.

You might also want to avoid "conservative", which might have lower performance than "powersave".

That's if for the basic performance governors, but I want to point out that, while performance governors and schedulers might seem "dumb" (probably because they are well-documented, and generally don't try the one-size-fits-all approach), they are well-proven and battle tested, from small embedded devices, to Android phones, to supercomputers.

There is also more to scheduling than performance governors, and the schedulers can have a role to play as well, but I don't think that gaming is the most complex scenario to handle, so this should make little difference, except for special cases.
My Manjaro system doesn't even have an interactive governor

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
performance powersave
Liam Dawe 23 Mar 2017
I've updated to link to the Arch Wiki for the resetting bit, according to the Wiki:
Depending on the scaling driver, one of these governors will be loaded by default:
ondemand for AMD and older Intel CPU.
powersave for Intel CPUs using the intel_pstate driver (Sandy Bridge and newer).
Xpander 23 Mar 2017
i have always used my keyboard macro buttons for forcing ondemand or performance. even with opengl it helped with the microstutering

my script is like that:

pkexec cpupower frequency-set -g performance && notify-send "Performance Mode" "Cpu clocks set to perfromance mode" -t 2000 -i messagebox_info

and other one for the ondemand mode also. pkexec is for polkit rule to not have to use root.
MayeulC 23 Mar 2017
...
My Manjaro system doesn't even have an interactive governor

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
performance powersave

Yeah, I remembered reading the other posts that it might not be standard. I don't have my computer with me ATM, unfortunately, so I can't check, but I will do in a couple hours.
"interactive" seems to be more of a real time governor, it looks more common on Android.

What I said is generally valid about "ondemand", though it ramps up a bit slower.

My bad, here I was thinking defaults were a bit less fragmented all over the place. Hey, that's part of the Linux charm, no? :D
jsa1983 23 Mar 2017
Thanks for the heads up, Liam. I made two files, called gov_perf and gov_psav and copied the short scripts into them, then made them executable and copied them to usr/bin. That way I can issue the commands from any directory with a single word typed. I'm sure I could add gov_perf to launcher scripts of games so that the process is auto-magic. Now to figure out a way to make games trigger gov_psav upon exit... ![](http://www.thethinkingatheist.com/forum/images/smilies/extra/consider.gif)

Maybe setting the following Steam game launch config works...

kdesu gov_perf ; %command% ; kdesu gov_psav 

(You can use whatever method you like to get privileges. kdesu is just an example)
haspadar 23 Mar 2017
I would give a try to schedutil (https://wiki.archlinux.org/index.php/CPU_frequency_scaling)
elmapul 23 Mar 2017
there is any way to delay an command to run only when the last command finish?


add an non steam game (it is an steam game, but do it anyway)
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ;
command to launch the game ;
echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

not tested!
M@GOid 23 Mar 2017
For a more easy way to change the settings, install the package "indicator-cpufreq"("sudo apt install indicator-cpufreq" for those of you in Ubuntu). It will show a icon in your taskbar were with 2 mouse clicks you can change to the Performance governor and back. I use it for both AMD and Intel CPUs for years and it works great, for any DE.
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.