Desktop Lag/Stuttering while gaming

Whenever I play any sort of game, whether it is graphically intensive or not I get massive delay/lag/tearing on everything but the game. I usually like to watch streams/videos or browse the net on my second monitor during some games but with this issue, it freezes up constantly. I’ve tried playing around with my xorg.conf file and doing the tweaks mentioned in the arch wiki to see if it would help, but it did not.

Here is info from inxi:

Kernel: 5.7.17-2-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.19.4 Distro: Manjaro Linux 
Machine:   Type: Desktop Mobo: Micro-Star model: MPG Z390 GAMING EDGE AC (MS-7B17) v: 2.0 
           UEFI: American Megatrends v: A.90 date: 06/11/2020 
CPU:       8-Core: Intel Core i7-9700K type: MCP speed: 800 MHz min/max: 800/4900 MHz 
Graphics:  Device-1: NVIDIA GP104 [GeForce GTX 1070] driver: nvidia v: 450.66 
           Display: x11 server: X.Org 1.20.8 driver: nvidia resolution: 1: 1920x1080~60Hz 2: 1600x900~60Hz 
           OpenGL: renderer: GeForce GTX 1070/PCIe/SSE2 v: 4.6.0 NVIDIA 450.66 

Any help or insight would be greatly appreciated. Thanks!

Hello,

Since is about KDE Plasma and Nvidia GPU, maybe you have to do what i do.
Open in Kate the /etc/X11/mhwd.d/nvidia.conf and in the Section "Device" replace the line Option "NoLogo" "1" with:

    Option         "TripleBuffer"  "On"
    Option  "ConnectToAcpid"    "Off"
    Option "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline = On}

Save it then create the file kwin.sh to use the triplebuffer, from terminal run:
echo "export KWIN_TRIPLE_BUFFER=1" | sudo tee /etc/profile.d/kwin.sh

Reboot after that and set the Compositor to OpenGL 3.1

Sometimes the for the kwin.sh is actually required to use:

export KWIN_TRIPLE_BUFFER=1
export __GL_YIELD=USLEEP
export __GL_MaxFramesAllowed=1

With this in place, do not try to run wayland session !

Some other situations/systems require that the nvidia.conf to have a fixed layout for Section "Screen", hence the metamodes goes there and all depends on the ports used and their order.

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Your GPU Name Model"
    Option         "TripleBuffer"  "On"
    Option  "ConnectToAcpid"    "Off"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-I-1: 1920x1080_60 +0+0 {ForceCompositionPipeline=On}, DVI-D-0: 1920x1080_60 +1920+0 {ForceCompositionPipeline=On}"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Yes, there is a difference between ForceCompositionPipeline and ForceFullCompositionPipeline and i don’t recommend to have them both enabled, and the ForceFull be used only if the other fails …

1 Like

Hi,

Thank you for the detailed reply!

So far, the issue is partly fixed!

After applying some of those settings, there seems to be no lag when I cap my FPS to my monitor’s refresh rate. If I try to go above 60FPS then the lag/stuttering returns when I go to other application but is perfectly ok in-game. Is there anything I can do about that? Don’t worry about it if it’s too much trouble.

Probably the second example of kwin.sh would be more suitable for you then, and if you have two different Monitors with different refresh rates each, then the fixed nvidia.conf layout would help and instead of _60 in the connector and resolution entry you use the real refresh rate capability of that Monitor. Then you have to make sure the same is used in Plasma Display System Settings.

1 Like

I believe I’ve found a fix. After toggling “Tearing prevention (vsync)” to “Never” in the compositor settings, the lag has seem to gone away. I rarely noticed tearing. It occasionally tears when dragging windows but that’s about it.

Appreciate you for taking the time to help!

Have you tried that without the kwin.sh and the additions to the nvidia.config i mentioned ?

Hello,

I reverted the changes made to the nvidia.conf & commented out the exports made in kwin.sh to see if there was a difference. There is no lag with those changes reverted and having Tearing prevention set to never.

So, the changes were never really needed and I simply just had to toggle that one option to never.

Again, appreciate the help!

Is always good to take note from other experiences, thanks for sharing yours and i’m glad you fixed your issue.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.