canonical / mir

The Mir compositor
GNU General Public License v2.0
643 stars 103 forks source link

Applications triggering high Mir CPU usage #3066

Open AlanGriffiths opened 1 year ago

AlanGriffiths commented 1 year ago

I suspect this is evdi related - it happens when I'm driving dual 1920x1600@60.0 monitors over DisplayLink.

Reproducer: FInd the pid of miriway and start a terminal with top -p <pid of miriway> docked left and gnome-monitor on the "resources" tab docked right.

With nothing else running that takes an excessive 24-33% CPU. If I put the outputs into clone mode, that jumps to around 70% CPU.

By comparison, I booted a ten year old laptop using the internal display: 2.7% CPU for the same apps.

Related to #3230?


[Original] I don't have a reproducer, so I don't know how much is relevant. But noting here in case more information comes to light.

  1. I was testing #2962 on evdi (DIsplayLink)
  2. I saw very high CPU usage (between 70% and 170%) by miral-shell when Firefox was on the active workspace (much less when switching to another workspace)
  3. After closing Firefox and using Chromium for a while CPU usage settled to a more reasonable reasonable 2-8%
  4. After reopening Firefox miral-shell CPU usage stayed mostly reasonable, with an occasional spike to 30% (these became less frequent over time)
Saviq commented 1 year ago

Can confirm, we need to look into what's going on here.

AlanGriffiths commented 9 months ago

I've now got similar high CPU usage in more scenarios.

AlanGriffiths commented 9 months ago

This does seem to be compositing related: forcing compositing to slow down (via --composite-delay 30) roughly halves these CPU usage figures.

AlanGriffiths commented 9 months ago

Trying the above "reproducer" with a (less old) laptop which has a 2560x1440@60 screen and Intel graphics:

CPU usage: 9%

And streaming a video from youtube:

CPU usage: 9%

Similarly, using Kodi to play the news through iPlayer:

CPU usage: 9%

Next, plugging in the DisplayLink dock (which added two 1920x1600@Hz monitors, cloned successfully in spite of #3239)

CPU usage: 115%

And reconfiguring the outputs so one is idle (and video on the main and first DL monitor):

CPU usage: 65%

And with even a fraction of the video on the third output:

CPU usage: 115%

Conclusion

  1. With the DisplayLink/evdi display driver, any update to the display is expensive (around 50% CPU in this configuration)
  2. This is not mitigated by any "damage" (I don't think we're optimising that anyway)
  3. All that an application needs to do to provoke this is to update at least one pixel every frame