HomePhorge
Poor desktop frame rate using KDE Neon with Wayland on NVIDIA

NOTE: TL;DR - GSP firmware loaded onto an on GPU RISC processor by the NVIDIA driver might be causing v-sync-miss type issues, causing fluctuations in frame rates. Jump to the bottom for instructions to disable this feature.

With the release of KDE Plasma 6 this year we saw a switch to Wayland from Xorg as the new default. I was in two minds about this switch, sceptical that it would actually be ready since every time I had tried Wayland I've encountered all sorts of compatibility issues, but on the flip side making it the default might be the push needed to get everything fixed. With this major release, it was probably a reasonable choice.

But of course there were problems... I won't bore you with the details of my specific issues, as some were a result of configuration changes I had made to get GPU acceleration working smoothly in some applications under X. But I was happy to see that since the release there have been regular updates and a lot of the issues seemed to get ironed out.

There has been one issue that continued to bother me (up until about 15 minutes before writing this). The desktop frame rate would fluctuate a lot and create a jerky or stuttering (as some people say) experience.

Today wasn't the first day I looked into this problem. I have gone around in circles a few times trying to understand what the problem was and trying to solve it. Since there are quite a number of components involved NVIDIA drivers, Linux Kernel, Wayland, Plasma (KWin) and Qt, it is easy to get lost in trial and error looking through posts online where people share "fixes" without helping to understand what's going on.

It looked to me as though it might have been a v-sync issue. I have my display at 60hz and the KDE frame rate widget (Settings -> Desktop Effects -> FPS) would show 30-40fps when rendering things. This can be a side effect of just missing the vsync interval when rendering which, if you do it every frame, can halve your framerate. It didn't seem to make much of a difference if it was just moving windows around or if an application was re-drawing content.

I looked at the KWin source to try and find options that I could change. I noticed that the KWIN_TRIPLE_BUFFER environment option wasn't referenced anymore. In fact I found there was a bit of auto detection in the code, which explains why the (quite old now) option to select the OpenGL mode (2 or 3) no longer appears. I ultimately didn't find any solutions looking through the KWIN source code.

It then occurred to me to try the nvidia-open driver. I switched from nvidia-driver-550 to nvidia-driver-550-open and found... not a solution.

I kept searching though but decided to focus on driver related issues. I eventually found these two posts on reddit.

As mentioned in the second link, the Nvidia documentation explains what the GPU System Processor (GSP) is designed to do. I checked the 550 documentation to see if it said anything different, since that was the one I was testing and sure enough, it was about the same.

So, I thought, if the driver was communicating with this processor in an sub optimal way then it could explain missed-v-sync type behaviour.

I ran nvidia-smi -q | grep GSP and saw a firmware version. So I set the module flag, rebooted, ran nvidia-smi -q | grep GSP again aaannnndd... GSP firmware still loaded. I was about ready to write my own desktop environment, driver and kernel at this point, but wondered if the open driver didn't support this module option.

I switched back to the proprietary driver and gave it one last shot...

60 FPS!

Smooth sailing again!

I haven't confirmed whether my thinking is correct, but I'm happy to accept that it is a likely explanation. This has already been a big side quest that I hadn't planned on accepting today, and another issue might pop up on a future update. So I'm going to set this aside for now.

To enable this yourself follow these instructions:

NOTE: I do not know if this will help with other desktop environments or any similar Xorg issues. But it is pretty easy to test.
  1. Create a file /etc/modprobe.d/nvidia-disable-gsp.conf
  2. Add the line:
options nvidia NVreg_EnableGpuFirmware=0
  1. Save then reboot
  2. Verify with:
nvidia-smi -q | grep GSP

You should see:

GSP Firmware Version                  : N/A

If a version number shows up then the option wasn't applied.

Alternatively you can copy this and past it into a shell:

disable-nvidia-gsp-firmware.sh
cat <<EOF | sudo tee -a /etc/modprobe.d/nvidia-disable-gsp.conf
# Disable GSP Firmware as explained https://sean.emblem.net.au/post/35/poor_desktop_frame_rate_using_kde_neon_with_wayland_on_nvidia/
#
# Originally discovered the solution via these posts:
#  https://www.reddit.com/r/arch/comments/1drq23o/comment/lbslwdy/
#  https://www.reddit.com/r/archlinux/comments/1ds6lbd/nvidianvreg_enablegpufirmware0_improves/

options nvidia NVreg_EnableGpuFirmware=0

EOF
NOTE: As mentioned, this does not work on the open drivers. If someone has an explanation or alternate option to set please let me know.

Now I know there is a RISC processor sitting idle on my GPU... I wonder if I can it would be useful for something...

Written by 0xseantasker on Sat, Nov 23, 3:49 PM.
User
Projects
None
Subscribers
None

Event Timeline