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: «4/4
  Go to:

Eike 24 Mar 2017
View PC info
  • Supporter Plus
I tested it, and it's never switching to „performance“ without command and I find this stupid.

That's how these settings are supposed to work, though: You decide about the governor (if you actually know about it), and the governor decides abotu you CPU speed. It doesn't magically switch governers, it magically switches speed (in the limits of what the governor is supposed to archive).

Does this mean that all the benchmarks of games were actually incorrect? I mean Windows vs Ubuntu (or Linux in general..)?

:-( I fear, rerunning some might be interesting...

*edit* If you do, don't forget to search for other possible optimizations in advance, like maybe this one: https://www.gamingonlinux.com/articles/you-will-want-to-force-your-cpu-into-high-performance-mode-for-vulkan-games-on-linux.9369/comment_id=89164


Last edited by Eike on 24 Mar 2017 at 2:57 pm UTC
Power-Metal-Games 24 Mar 2017
*edit* If you do, don't forget to search for other possible optimizations in advance, like maybe this one: https://www.gamingonlinux.com/articles/you-will-want-to-force-your-cpu-into-high-performance-mode-for-vulkan-games-on-linux.9369/comment_id=89164

I do not do benchmarks at all, but someone should inform these guys that do it about this. nVidia GPUs are switching performance levels all the time like expected. I thought that with CPUs everything was the same...
Eike 24 Mar 2017
View PC info
  • Supporter Plus
nVidia GPUs are switching performance levels all the time like expected. I thought that with CPUs everything was the same...

But they do! Their performance levels are called Mhz, not governer.
Power-Metal-Games 24 Mar 2017
But they do! Their performance levels are called Mhz, not governer.

I found something new which is also strange. When Ubuntu boot, for 2-3 minutes it shows that its in „performance“ mode. After that time, it switches to "powersave" and rest in that mode all the time.
This is seriously stupid whoever invented this. It should work automatically but it doesn't work at all.
dubigrasu 24 Mar 2017
I benchmarked Talos with all the governors on my Core i5 4690K, in Vulkan mode, on Linux 4.9.6 with nvidia 375.26.

Long story short:
- intel_pstate performance and powersave give the same framerate (76.5 FPS).
- acpi_cpufreq ondemand and conservative achieve the best performance (78.7 FPS).

Both CPU core 0 usage and GPU usage were 100% when I benchmarked in Ultra quality, but I tried again with the GPU Speed setting set to Medium to make sure the GPU wasn’t the bottleneck and still got the same framerate for intel_pstate performance and powersave (~240 FPS).
EDIT: I also tried the opposite, CPU Medium and GPU Ultra, again same framerate.

As for OpenGL all the governors gave the same framerate (55 FPS) except acpi_cpufreq powersave (29 FPS).

I have some mixed Intel results here showing that overall there's not much difference indeed in average FPS. http://openbenchmarking.org/result/1605221-DE-ALLGOVERN95
However, it can be a significant improvement in alleviating the stutter especially in not so demanding games (where the CPU gets down-clocked frequently).
Also it was something much more visibly on my previous AMD CPU.
Thing is, fiddling around with governors is not something that will give instant guaranteed boost in performance on every game and every CPU out there, but is something worth trying when you want to squeeze some more oomph from your CPU.
Typijay 25 Mar 2017
I wonder if this will fix the stuttering in Borderlands 2 even with gl threaded enabled. I guess there's only one way to find out...
dubigrasu 25 Mar 2017
I wonder if this will fix the stuttering in Borderlands 2 even with gl threaded enabled. I guess there's only one way to find out...
There's a short test here with my old AMD CPU (try to watch it in 1080p HD to see the graph more clearly):
View video on youtube.com
Ardje 27 Mar 2017
I wish there was a way to not have to put in my password on every change, maybe someone knows how to work around that?

You could give setuid a try. Make a shell script as root, and then: chmod u+s script.sh
You should be able to run it as a user with it's owner rights, which are root.

No go on my Arch system. I've also tried editing the sudoers config file with visudo and using sudo instead, but that still asks for a password :/
I don't know what the discussion is, but running scripts as root is easy:
You create a script that's owned by root in a directory that's only writeable by root (security).
In your script you do
if [ "$(id -u)" -ne 0 ]; then
exec sudo -u root "$0" "$@"
fi

In your sudoers file you can say:
<user> ALL = NOPASSWD: <full path of your script>

That's the easiest way to perform a script as root: make the script safe, and then hand out rights to users to run that script.
Cybolic 27 Mar 2017
[...]
That's the easiest way to perform a script as root: make the script safe, and then hand out rights to users to run that script.
That's what I did, but for some reason it won't work with Argos. I assume it's due to per-terminal login / "tty_tickets", which I don't want to disable completely.
lucifertdark 27 Mar 2017
I tried this the other day when you posted it & the cpu kept overheating, turns out one of the clips that are supposed to hold the fan in place had broken & it wasn't sitting against the cpu so cooling wasn't happening at all, one refresh of the thermal paste & a new fan later & no more overheating, thanks to you Liam I got a potentially cpu threatening problem fixed. :D
Eike 27 Mar 2017
View PC info
  • Supporter Plus
I tried this the other day when you posted it & the cpu kept overheating, turns out one of the clips that are supposed to hold the fan in place had broken & it wasn't sitting against the cpu so cooling wasn't happening at all, one refresh of the thermal paste & a new fan later & no more overheating, thanks to you Liam I got a potentially cpu threatening problem fixed. :D

Cool!

... in both meanings of the word! :D
lucifertdark 27 Mar 2017
Cool!

... in both meanings of the word! :D
He didn't so much save my bacon as save my chips. ;)
ronnoc 27 Mar 2017
AMD 8370 proc here running RadeonSI. I can't successfully run any of the above scripts, as I do not have that folder structure on my system (KDE Neon). My '/sys/devices/system/cpu/cpufreq/' folder is empty.
elmapul 27 Mar 2017
from an comunity on google Plus

"Jannis
I use a file in /etc/sudoers.d/ to allow commands I want to run with sudo from scripts without password:

# cat /etc/sudoers.d/20-customstuff
jannis ALL=(ALL) NOPASSWD: /usr/bin/openvpn, /usr/bin/cpupower, /usr/local/bin/cryptmount.sh, /usr/bin/radeontop, /usr/bin/psd-overlay-helper, /usr/local/bin/emsync.sh

This allows to run certain commands or scripts with sudo without entering a password.

I put my custom scripts into /usr/local/bin/ as that's owned by root, in path variable, and won't conflict with the package manager. I also "chown root:root" and "chmod 755" my scripts to prevent privilege escalation.

Anyway, to toggle cpu governors, I made a small script¹ and set it to execute on keypress on one of the custom keys on my roccat keyboard. It uses /usr/bin/cpupower which is in the NOPASSWD line mentioned above.

¹ pastebin.com - [Bash] /usr/local/bin/toggleperformance - Pastebin.com
[Bash] /usr/local/bin/toggleperformance - Pastebin.com
[Bash] /usr/local/bin/toggleperformance - Pastebin.com
pastebin.com"

https://pastebin.com/vj6jD8bE
lucifertdark 4 Apr 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)
You know you could add them as bash aliases as well? they would then work from terminal, tested & fully working here. :D

alias perform='echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'Gives you performance &

alias demand='echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'puts it back to ondemand.

put those lines in your .bash_aliases file & you're good to go.


Last edited by lucifertdark on 4 Apr 2017 at 5:38 pm UTC
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.