NVIDIA Lands Fix To Avoid High CPU Usage When Using The KDE Desktop
For nearly six years there has been a bug report about high CPU load when using the NVIDIA proprietary driver causing high CPU load when running the KDE desktop and making use of double buffering. This issue has been finally resolved.
Bug #322060 has finally been closed following a recent commit to KWin by NVIDIA engineer Erik Kurzinger -- this is the same developer working on the EGLStreams code for KDE/KWin, albeit in this case this bug fix is on the X.Org side and unrelated to that effort. The mentioned bug has been open since the summer of 2013 for double buffering with NVIDIA GPUs causing high CPU load. As mentioned in that posting, a workaround has been to set the __GL_YIELD=USLEEP environment variable to avoid the excessive CPU resource usage. But Kurzinger has worked out the underlying issue after the problem eluded KDE developers for years.
This didn't end up being a NVIDIA driver issue itself but rather KWin making an incorrect assumption about GLX's swap buffers operation. Erik explained, "The NVIDIA implementation of glXSwapBuffers will, by default, queue up to two frames for presentation before blocking. KWin's compositor, however, assumes that calls to glXSwapBuffers will always block until the next vblank when rendering double buffered. This assumption isn't valid, as glXSwapBuffers is specified as being an implicit glFlush, not an implicit glFinish, and so it isn't required to block. When this assumption is violated, KWin's frame timing logic will break."
The change to address this is quite easy and was applied to KDE: set the __GL_MaxFramesAllowed=1 environment variable as it will cause the NVIDIA driver then to always block until the next re-trace, matching the behavior of KWin. So this change is now in place for the next KDE Plasma release (Plasma 5.16, not clear if it will be back-ported to a 5.15 point release) or users can also set this environment variable on their own too if experiencing lag when moving windows and/or high CPU usage.
Bug #322060 has finally been closed following a recent commit to KWin by NVIDIA engineer Erik Kurzinger -- this is the same developer working on the EGLStreams code for KDE/KWin, albeit in this case this bug fix is on the X.Org side and unrelated to that effort. The mentioned bug has been open since the summer of 2013 for double buffering with NVIDIA GPUs causing high CPU load. As mentioned in that posting, a workaround has been to set the __GL_YIELD=USLEEP environment variable to avoid the excessive CPU resource usage. But Kurzinger has worked out the underlying issue after the problem eluded KDE developers for years.
This didn't end up being a NVIDIA driver issue itself but rather KWin making an incorrect assumption about GLX's swap buffers operation. Erik explained, "The NVIDIA implementation of glXSwapBuffers will, by default, queue up to two frames for presentation before blocking. KWin's compositor, however, assumes that calls to glXSwapBuffers will always block until the next vblank when rendering double buffered. This assumption isn't valid, as glXSwapBuffers is specified as being an implicit glFlush, not an implicit glFinish, and so it isn't required to block. When this assumption is violated, KWin's frame timing logic will break."
The change to address this is quite easy and was applied to KDE: set the __GL_MaxFramesAllowed=1 environment variable as it will cause the NVIDIA driver then to always block until the next re-trace, matching the behavior of KWin. So this change is now in place for the next KDE Plasma release (Plasma 5.16, not clear if it will be back-ported to a 5.15 point release) or users can also set this environment variable on their own too if experiencing lag when moving windows and/or high CPU usage.
46 Comments