Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. High GPU usage when animating
Forum Updated to NodeBB v4.3 + New Features

High GPU usage when animating

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 2.9k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jpsjanne
    wrote on 25 Nov 2020, 12:58 last edited by
    #1

    Hello,

    I've been developing a Qt application in my company. Lately I've received reports of significantly high GPU usage in Windows 10 in the application during animations. While pinpointing the cause, I noticed that even the basic Qt examples can exhibit this problem.

    Steps to reproduce:

    • Open Qt Creator, select "OpenGL Window Example" in Examples and run the application
    • Open Task Manager and observe GPU usage
      • If nothing happens, try maximizing and minimizing the application window, and activating and moving other windows around
      • Sometimes it takes up to 20 seconds before the GPU usage increases

    What is also notable, is that it's not only the application that consumes the GPU, but Desktop Window Manager participates always as well:
    process.png

    This is a desktop computer with one GPU, NVIDIA GeForce GTX 1070Ti, which should not budge from such a simple 3D task. What is peculiar in this case is that the GPU load varies intensely. The following is a snapshot of ~60 seconds of runtime, without any other particular activity:
    gpu.png

    The lowest values around ~5% is something that could be expected when running the example in fullscreen in WQHD. But GPU load around 30-40% should not happen.

    Other observations:

    • This problem is very inconsistent. Sometimes the GPU load is within acceptable levels, but it can ramp up unexpectedly. Sometimes it remains high throughout the whole run time.
    • Tweaking QSurfaceFormat settings seems to have no impact.
    • Desktop Window Manager (dwm.exe) seems to always contribute roughly the same amount of GPU usage as the Qt app.
    • Other 3D software does not produce unreasonably high GPU usage, nor do they make DWM consume resources more than a couple of percents at max. This seems to be particular to apps developed in Qt.
    • Window size or state do not affect the results consistently, i.e. a tiny window can still consume GPU. Likewise, a maximized window does not always consume large amounts of GPU resources. Desktop scaling doesn't seem to have an effect.
    • Tested different Qt-versions (up from 5.12) and compilers (MSVC, MinGW), no effect.
    • This issue is not particular to any specific Qt application; Any application (that I've tested) with openGL content, including QML applications, running constant animations/updates have this issue.
    • Switching to D3D12 (QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Direct3D12) ) seems to set the application to minimal GPU usage, but then DWM GPU usage doubles.
    • The problem has been reported to occur also on other Windows 10 computers.

    Any idea what could be the cause?

    M 1 Reply Last reply 25 Nov 2020, 15:22
    1
    • J jpsjanne
      25 Nov 2020, 12:58

      Hello,

      I've been developing a Qt application in my company. Lately I've received reports of significantly high GPU usage in Windows 10 in the application during animations. While pinpointing the cause, I noticed that even the basic Qt examples can exhibit this problem.

      Steps to reproduce:

      • Open Qt Creator, select "OpenGL Window Example" in Examples and run the application
      • Open Task Manager and observe GPU usage
        • If nothing happens, try maximizing and minimizing the application window, and activating and moving other windows around
        • Sometimes it takes up to 20 seconds before the GPU usage increases

      What is also notable, is that it's not only the application that consumes the GPU, but Desktop Window Manager participates always as well:
      process.png

      This is a desktop computer with one GPU, NVIDIA GeForce GTX 1070Ti, which should not budge from such a simple 3D task. What is peculiar in this case is that the GPU load varies intensely. The following is a snapshot of ~60 seconds of runtime, without any other particular activity:
      gpu.png

      The lowest values around ~5% is something that could be expected when running the example in fullscreen in WQHD. But GPU load around 30-40% should not happen.

      Other observations:

      • This problem is very inconsistent. Sometimes the GPU load is within acceptable levels, but it can ramp up unexpectedly. Sometimes it remains high throughout the whole run time.
      • Tweaking QSurfaceFormat settings seems to have no impact.
      • Desktop Window Manager (dwm.exe) seems to always contribute roughly the same amount of GPU usage as the Qt app.
      • Other 3D software does not produce unreasonably high GPU usage, nor do they make DWM consume resources more than a couple of percents at max. This seems to be particular to apps developed in Qt.
      • Window size or state do not affect the results consistently, i.e. a tiny window can still consume GPU. Likewise, a maximized window does not always consume large amounts of GPU resources. Desktop scaling doesn't seem to have an effect.
      • Tested different Qt-versions (up from 5.12) and compilers (MSVC, MinGW), no effect.
      • This issue is not particular to any specific Qt application; Any application (that I've tested) with openGL content, including QML applications, running constant animations/updates have this issue.
      • Switching to D3D12 (QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Direct3D12) ) seems to set the application to minimal GPU usage, but then DWM GPU usage doubles.
      • The problem has been reported to occur also on other Windows 10 computers.

      Any idea what could be the cause?

      M Offline
      M Offline
      mooglus
      wrote on 25 Nov 2020, 15:22 last edited by
      #2

      @jpsjanne I've got no solution for you but wanted to add that we experience very high GPU usage on iOS with animation and QML. In fact any kind of on screen change eats up GPU. Battery-life is significantly hit and iPads get very hot, I'll be watching this thread with interest. We've used Qt on this particular project since 5.9 and the high GPU issue has persisted all along.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 25 Nov 2020, 23:05 last edited by Kent-Dorfman
        #3

        two things...first, you need to meter your performance outside of the Creator, not running the app from within creator. an IDE could be doing implicit profiling that interferes with getting real numbers from the OS.

        Second, compare sample program load by running instances compiled optimized and then with full debugging enabled.

        and as a final note, why do you care about GPU utilization? as long as it's not starved you shouldn't care because that utilization is generally only reflecting the rendering pipeline...real CPU utilization is where I would worry.

        J 1 Reply Last reply 26 Nov 2020, 06:39
        2
        • K Kent-Dorfman
          25 Nov 2020, 23:05

          two things...first, you need to meter your performance outside of the Creator, not running the app from within creator. an IDE could be doing implicit profiling that interferes with getting real numbers from the OS.

          Second, compare sample program load by running instances compiled optimized and then with full debugging enabled.

          and as a final note, why do you care about GPU utilization? as long as it's not starved you shouldn't care because that utilization is generally only reflecting the rendering pipeline...real CPU utilization is where I would worry.

          J Offline
          J Offline
          jpsjanne
          wrote on 26 Nov 2020, 06:39 last edited by
          #4

          @Kent-Dorfman

          I've tested both debug and release versions in Qt Creator and standalone release versions. All tests show far have exhibited the same behavior.

          There are a lot of reasons to care about GPU utilization:

          • We are deploying our software on industrial low-end computers, which do not have powerful GPUs
            • They may also in some cases rely only on battery
            • They may also be running other critical applications requiring GPU resources, which our software should attempt to preserve
          • The GPU load is unreasonable
            • For comparison, I can view an animated high-poly 3D model on Sketchfab with the same GPU load as viewing a spinning triangle in a Qt app
            • This kind of thing can negatively impact the company image. Our software runs on a small window but still manages to clog the GPU, which would not be viewed positively by our customer base. Conserving computation resources is definitely a key point in our field of business
          • This could be a bug
            • The 3D chart that I posted depicts that the GPU load varies drastically, albeit the rendering task doesn't
            • If the same issue is affecting other developers and other platforms, I think it's worth investigating further
          J 1 Reply Last reply 26 Nov 2020, 06:47
          1
          • J jpsjanne
            26 Nov 2020, 06:39

            @Kent-Dorfman

            I've tested both debug and release versions in Qt Creator and standalone release versions. All tests show far have exhibited the same behavior.

            There are a lot of reasons to care about GPU utilization:

            • We are deploying our software on industrial low-end computers, which do not have powerful GPUs
              • They may also in some cases rely only on battery
              • They may also be running other critical applications requiring GPU resources, which our software should attempt to preserve
            • The GPU load is unreasonable
              • For comparison, I can view an animated high-poly 3D model on Sketchfab with the same GPU load as viewing a spinning triangle in a Qt app
              • This kind of thing can negatively impact the company image. Our software runs on a small window but still manages to clog the GPU, which would not be viewed positively by our customer base. Conserving computation resources is definitely a key point in our field of business
            • This could be a bug
              • The 3D chart that I posted depicts that the GPU load varies drastically, albeit the rendering task doesn't
              • If the same issue is affecting other developers and other platforms, I think it's worth investigating further
            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 26 Nov 2020, 06:47 last edited by
            #5

            @jpsjanne I suggest to bring this topic to the Qt bug tracker, as Qt developers have better insights in this topic I think.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            J 1 Reply Last reply 28 Nov 2020, 06:08
            0
            • K Offline
              K Offline
              Kent-Dorfman
              wrote on 26 Nov 2020, 06:49 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • J jsulm
                26 Nov 2020, 06:47

                @jpsjanne I suggest to bring this topic to the Qt bug tracker, as Qt developers have better insights in this topic I think.

                J Offline
                J Offline
                jpsjanne
                wrote on 28 Nov 2020, 06:08 last edited by jpsjanne
                #7

                @jsulm Thanks for the suggestion, it might be the best approach.

                Edit. Issue: https://bugreports.qt.io/browse/QTBUG-88980

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jpsjanne
                  wrote on 2 Dec 2020, 10:23 last edited by
                  #8

                  Okay, the issue got resolved after a myriad of various tests. The root cause proved to be quite simple: GPU power save.

                  Since Qt programs use VSync by default, and the rendering task is small, this triggered the GPU to reduce its clock frequency to save power. Counter-intuitively, Task Manager displays an increase in GPU utilization, as it only displays the utilization of the current resources, not the total available resources of the GPU. The power save decision process is unpredictable, which causes the sporadic increase & decrease in GPU utilization.

                  Also, DWM is consuming a constant amount of GPU, but it appears to increase consumption only because the total amount of resources decreases.

                  Therefore, when evaluating Qt performance GPU-wise, looking only at the GPU utilization makes sense only if the application is configured to use the maximum performance when the application is running:

                  nvidia.png

                  The actual clock frequency can be seen for example with GPU-Z:
                  gpuz.png

                  As an additional side note to GPU performance evaluation, what should be also considered is dual-GPU laptops. Many laptops have a more powerful dedicated GPU in addition to the low-end integrated GPU. Qt applications seem to be running on the integrated GPU by default. While it's possible to manually set the active GPU for applications, it is also possible to force the use of the dedicated GPU programmatically:
                  https://stackoverflow.com/a/39047129

                  I'm withdrawing the bug report since there's nothing to fix. Hopefully these discoveries will be useful for other developers who are scratching their heads on the same issue.

                  1 Reply Last reply
                  3
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 2 Dec 2020, 18:58 last edited by
                    #9

                    Thanks for the detailed feedback !

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    1/9

                    25 Nov 2020, 12:58

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved