You are not logged in.

#1 2023-05-23 09:47:53

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Nvidia Optimus stuttering when monitor is connected to dGPU

I'm using Arch on an MSI GE76 Raider with optimus enabled. I've tried everything I can think of to fix this, and nothing has really worked. I've tried searching for this issue online and can't find anyone else reporting anything similar. If anyone knows a solution to this problem, it would be much appreciated!

Getting optimus working properly on linux has been a challenge. The reason I switched to Arch from the ubuntu-based distribution I've been using was in a last ditch effort to see if it fixed some horrible lag issues I'd get whenever optimus was on as well as some other lag issues. Fortunately, in addition to me liking it more than ubuntu in general, Arch has been working 1000x better on this computer than ubuntu was, including with optimus. For most things, optimus is working better than it was on windows as well.

It's almost been perfect, except that when there is a display connected to the nvidia GPU through the display outs, any 3D accelerated app will have stutters. At first I thought it was always doing it, until I took my laptop out about 2 days ago and realized that the issue disappeared until I arrived home and plugged it into my monitor. It's a constant stutter, almost like dropped frames. It happens regardless of which GPU the program is running on, or which display the window is on. I can also see the stutter when looking at an fps counter.  The moment the external monitor is disconnected, the issue is gone. It's not *unusable* most of the time, I've played some games just fine with the stutter, but it is noticeable and heavily affects the smoothness of the image. This stutter does not happen on the desktop, 2d accelerated apps, or videos. It happens regardless of what mode nvidia prime is set to.

The only thing that I have found that "solves" the problem is installing the xf86-video-intel package, but apparently nvidia driver version 530 makes it so that prime synchronization is completely broken when that other driver is installed, so the external display will only refresh when the mouse is moved on it. 3D performance also gets nuked, but I'm not sure if that's the new nvidia driver's fault or not. I tried downgrading to version 525 which has been reported to work properly with the intel drivers, but it just refuses to load the kernel module at all no matter what I try. I tried the linux zen kernel as a "probably wont work but ill try it anyways" solution, and it just made everything infinitely worse immediately so I didn't even bother trying to install the driver and went back to the normal one.

Since the issue only happens when there's a display on the nvidia gpu, I thought maybe I could just not have any of my displays connected to it. One of my external monitors is already plugged to the iGPU through a USB 3 type c dock, so I can just plug my other external monitor to it as well. Main issue with that is that my main monitor is 144hz, and plugging both external monitors into the dock caps both my 144hz primary and 75Hz secondary monitors at 75Hz. I could see if a thunderbolt dock would work instead, but I would have to try someone else's to test that theory since I do not have one. Even if that solution worked, there is no way to connect an external display to the iGPU on this laptop without a usb c to display adapter since both of the physical display ports on the laptop are wired to the Nvidia GPU.  I can imagine several situations where I would want to bring my laptop somewhere, connect to an external display, and run a 3d app without having to have a usb c to hdmi adapter on me.

Disabling optimus fixes the issue entirely, but as someone who is quite fond of having more than 50 minutes of battery life and being able to split tasks across the GPUs I would greatly prefer not to do that.

Is there a solution to this, or do I just have to wait for the slim possibility that Nvidia fixes their linux drivers?

Last edited by queenbiscuit311 (2023-05-23 09:51:40)

Offline

#2 2023-05-23 12:12:52

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

How does the intel driver solve the "stutter" when it basically stalls the output?
Remove that driver again.

How frequent is the stutter?
Does it remain when you turn off prime-sync?
https://wiki.archlinux.org/title/PRIME# … erse_PRIME

Offline

#3 2023-05-23 20:29:37

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

How does the intel driver solve the "stutter" when it basically stalls the output?

It breaks the output to the Nvidia monitor only, and I can still see on the Nvidia monitor when moving the mouse on it. I loaded up a simple game that was one of the worst ones in terms of stutter and the problem was completely gone, but due the video output being broken I uninstalled the driver a while ago since I could never get the older drivers working.

How frequent is the stutter?

It's pretty much constant, there's no period where it's not stuttering at all. I could make and send a link to a simple video recording of what I'm talking about if you'd like.

Does it remain when you turn off prime-sync?

It goes away on any monitors connected to my iGPU, but then lowers to fps of doing anything except moving windows on the Nvidia monitor to like 3 seconds per frame, so unfortunately it's not very usable. Even just typing in the terminal was very laggy.

Offline

#4 2023-05-23 20:57:46

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

It's pretty much constant, there's no period where it's not stuttering at all.

Sorry, what I meant was "how many frames per second hang"

Please post the output of "xrandr -q" w/ both outputs attached.

What Desktop Environment / windowmanager do you run on this system? Compositor?
(still) KDE (or as well)?
What if you suspend the compositor (SHIFT+Alt+F12)?

Offline

#5 2023-05-23 21:32:27

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

Sorry, what I meant was "how many frames per second hang"

Oh, I see. I'm not entirely sure, I have mangohud installed so I'll see if I can at least see a framtime graph. The framerate average of whatever app I'm using doesn't seem to ever dip below 10 fps below target if running at the full display refresh rate. For example, glxgears will sometimes dip from 144fps to 138 or 136 average, rarely 134 or 135. Pretty much same thing for some other programs I have that can reach a locked 144fps. It's less comparable to a hang, and more comparable to the dropped frames from watching a youtube video at 1080p on a laptop that's slightly too old for it, if that analogy makes any sense.

xrandr -q outputs the following:

Screen 0: minimum 320 x 200, current 5760 x 1080, maximum 16384 x 16384
eDP-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 382mm x 215mm
   1920x1080    144.03*+  60.01    59.97    59.96    60.01    59.93  
   1680x1050     59.95    59.88  
   1400x1050     74.76    59.98  
   1600x900      59.99    59.94    59.95    59.82  
   1280x1024     85.02    75.02    60.02  
   1400x900      59.96    59.88  
   1280x960      85.00    60.00  
   1440x810      60.00    59.97  
   1368x768      59.88    59.85  
   1280x800      59.99    59.97    59.81    59.91  
   1152x864      75.00  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      85.00    75.05    60.04    85.00    75.03    70.07    60.00  
   1024x768i     86.96  
   960x720       85.00    75.00    60.00  
   928x696       75.00    60.05  
   896x672       75.05    60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   832x624       74.55  
   960x540       59.96    59.99    59.63    59.82  
   800x600       85.00    75.00    70.00    65.00    60.00    85.14    72.19    75.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       74.76    59.98  
   800x450       59.95    59.82  
   640x512       85.02    75.02    60.02  
   700x450       59.96    59.88  
   640x480       85.09    60.00    85.01    72.81    75.00    59.94  
   720x405       59.51    58.99  
   720x400       85.04  
   684x384       59.88    59.85  
   640x400       59.88    59.98    85.08  
   576x432       75.00  
   640x360       59.86    59.83    59.84    59.32  
   640x350       85.08  
   512x384       85.00    75.03    70.07    60.00  
   512x384i      87.06  
   512x288       60.00    59.92  
   416x312       74.66  
   480x270       59.63    59.82  
   400x300       85.27    72.19    75.12    60.32    56.34  
   432x243       59.92    59.57  
   320x240       85.18    72.81    75.00    60.05  
   360x202       59.51    59.13  
   360x200       85.04  
   320x200       85.27  
   320x180       59.84    59.32  
   320x175       85.27  
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-2-1 connected 1920x1080+3840+0 (normal left inverted right x axis y axis) 600mm x 330mm
   1920x1080     60.00 +  74.97*   50.00    59.94  
   1680x1050     59.88  
   1280x1024     75.02    60.02  
   1440x900      59.90  
   1280x960      60.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
DP-2-2 disconnected (normal left inverted right x axis y axis)
DP-2-3 disconnected (normal left inverted right x axis y axis)
DP-1-0 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 598mm x 336mm
   1920x1080     60.00 + 144.00*  119.98   119.88    99.93    74.97    59.94    50.00  
   1280x1024     75.02    60.02  
   1280x720      59.94    50.00  
   1024x768     119.99    99.97    75.03    70.07    60.00  
   800x600      119.97    99.66    75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480      119.52    99.77    75.00    72.81    59.94    59.93  
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-0 disconnected (normal left inverted right x axis y axis)
DP-1-2 disconnected (normal left inverted right x axis y axis)
DP-1-3 disconnected (normal left inverted right x axis y axis)
DP-1-4 disconnected (normal left inverted right x axis y axis)
  1920x1080 (0xcc) 148.500MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  60.00Hz
  1920x1080 (0xce) 148.500MHz +HSync +VSync
        h: width  1920 start 2448 end 2492 total 2640 skew    0 clock  56.25KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  50.00Hz
  1280x1024 (0x58) 135.000MHz +HSync +VSync
        h: width  1280 start 1296 end 1440 total 1688 skew    0 clock  79.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  75.02Hz
  1280x1024 (0x59) 108.000MHz +HSync +VSync
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
  1280x720 (0xd2) 74.250MHz +HSync +VSync
        h: width  1280 start 1720 end 1760 total 1980 skew    0 clock  37.50KHz
        v: height  720 start  725 end  730 total  750           clock  50.00Hz
  1024x768 (0x6f) 78.750MHz +HSync +VSync
        h: width  1024 start 1040 end 1136 total 1312 skew    0 clock  60.02KHz
        v: height  768 start  769 end  772 total  800           clock  75.03Hz
  1024x768 (0x70) 75.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1328 skew    0 clock  56.48KHz
        v: height  768 start  771 end  777 total  806           clock  70.07Hz
  1024x768 (0x71) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  800x600 (0x8c) 49.500MHz +HSync +VSync
        h: width   800 start  816 end  896 total 1056 skew    0 clock  46.88KHz
        v: height  600 start  601 end  604 total  625           clock  75.00Hz
  800x600 (0x8b) 50.000MHz +HSync +VSync
        h: width   800 start  856 end  976 total 1040 skew    0 clock  48.08KHz
        v: height  600 start  637 end  643 total  666           clock  72.19Hz
  800x600 (0x8d) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  800x600 (0x8e) 36.000MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock  35.16KHz
        v: height  600 start  601 end  603 total  625           clock  56.25Hz
  720x576 (0xd4) 27.000MHz -HSync -VSync
        h: width   720 start  732 end  796 total  864 skew    0 clock  31.25KHz
        v: height  576 start  581 end  586 total  625           clock  50.00Hz
  720x480 (0xd6) 27.000MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.47KHz
        v: height  480 start  489 end  495 total  525           clock  59.94Hz
  640x480 (0xa0) 31.500MHz -HSync -VSync
        h: width   640 start  656 end  720 total  840 skew    0 clock  37.50KHz
        v: height  480 start  481 end  484 total  500           clock  75.00Hz
  640x480 (0xa1) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz

What Desktop Environment / windowmanager do you run on this system? Compositor?
(still) KDE (or as well)?

I'm currently running KDE Plasma with KWin as the window manager/compositor. I could try a different desktop environment or window manager to see if anything changes.

Suspending the compositor seems to have heavily alleviated the problem. Now instead of stuttering, it'll just kind of hitch for like 5-ish frames every hundred frames or so. The moment I start the compositor again the issue returns.

Offline

#6 2023-05-24 03:21:18

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

Looking into this further as a compositor-caused issue, it would appear I am not the only one with stuttering issues on kwin, although none of the reports ive seen quite match my description. I'm going to try a different compositor and see if that does something.

Last edited by queenbiscuit311 (2023-05-24 03:21:50)

Offline

#7 2023-05-24 03:42:38

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

Everything I can find on stuttering with kwin is stutter when doing anything, not just 3d accelerated apps. I just can't find anything resembling the specific issue I'm having at all. Literally only relevant result I've found while googling is this exact post that I just made.

Last edited by queenbiscuit311 (2023-05-24 03:47:38)

Offline

#8 2023-05-24 04:02:17

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

Alright, actually I stand corrected about it only happening when optimus is on. While it's nowhere near as bad in Nvidia only mode, the stutter indeed is still there and goes away almost entirely (with still a bit of hitching like i described earlier) when the compositor is disabled, at the cost of heavy screen tearing. at least this might narrow my search for a solution a bit since it's apparently not entirely optimus' fault.

Also noticing that when the compositor is on my framerate dips by 7-12%

Last edited by queenbiscuit311 (2023-05-24 04:11:29)

Offline

#9 2023-05-24 04:23:08

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

Sorry for all the posts I keep finding new stuff about this the more i mess with my computer. it would appear my statement that the stutter only occurs in 3d apps is completely wrong, i just didnt notice that it also happened in almost everything else because it is a lot more subtle. it is definitely stuttering when i move windows and the like. disabling the compositor seems to fix this too. issue is none of the other compositors i've tried are working properly either, but ill keep trying stuff and see if anything sticks. It does seem like my original description of the problem is completely wrong, however.

Last edited by queenbiscuit311 (2023-05-24 04:24:05)

Offline

#10 2023-05-24 09:45:44

queenbiscuit311
Member
Registered: 2023-05-17
Posts: 64

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

Alright so, I've accepted that the benefits from having optimus off outweighs all the crap i have to deal with just to be able to use my battery without restarting the few times I want to. I'll see if I can fix the little bit of compositor lag I'm still dealing with, but i've changed some settings and i *think* its mostly gone.

Offline

#11 2023-05-24 14:52:37

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: Nvidia Optimus stuttering when monitor is connected to dGPU

There're three outputs, two at 144Hz, one at 75 Hz.
What if you run them all at 60Hz?

Offline

Board footer

Powered by FluxBB