gnome-shell high CPU utilization when moving a high frequency mouse

Bug #2051383 reported by Sergey Zolotarev
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
gnome-shell (Ubuntu)
Confirmed
Undecided
Daniel van Vugt
gnome-shell-extension-desktop-icons-ng (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

When I simply move my mouse cursor on an empty desktop, gnome-shell's CPU usage goes up from 20% (when idle) to 60%, which causes stuttering.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: gnome-shell 42.9-0ubuntu2
ProcVersionSignature: Ubuntu 6.5.0-15.15~22.04.1-generic 6.5.3
Uname: Linux 6.5.0-15-generic x86_64
NonfreeKernelModules: zfs
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Fri Jan 26 23:31:26 2024
DisplayManager: gdm3
EcryptfsInUse: Yes
InstallationDate: Installed on 2018-03-17 (2140 days ago)
InstallationMedia: Ubuntu 18.04 LTS "Bionic Beaver" - Alpha amd64 (20180316)
RebootRequiredPkgs: Error: path contained symlinks.
RelatedPackageVersions: mutter-common 42.9-0ubuntu5
SourcePackage: gnome-shell
UpgradeStatus: Upgraded to jammy on 2022-06-02 (603 days ago)

Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

20% when idle is 20% too much. So if we find out what that is then the 60% might become 40%.

Do you have any extra gnome-shell extensions active? Can you provide a photo or screenshot of the desktop?

Changed in gnome-shell (Ubuntu):
status: New → Incomplete
tags: added: cursor performance
Revision history for this message
Sergey Zolotarev (szx) wrote :

I'm sorry, the 20% part was a bit of an overstatement, after observing more I can say it's somewhere between 1% to 5%.

I have the following extensions active:
- Desktop Icons NG
- Ubuntu AppIndicators
- Ubuntu Dock

Disabling all extensions didn't change anything in my case.

Also I've noticed an interesting thing: when moving the cursor, CPU usage goes up for gnome-shell AND for whatever process on top of whose window I"m moving it. For example, if a Text Editor window is active, it goes up for the gedit process.

If it helps, below are a few screenshots of "top" taken when I moved my mouse, with Xorg and Wayland for comparison, and a video.

Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Sergey Zolotarev (szx) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yes it's normal for the application's CPU usage to go up when it's receiving input events. So that suggests this is just a high frequency problem.

* Is your log flooding at all? (journalctl -f)

* I can already see you monitor is 144Hz. What model of mouse are you using?

* Try adding MUTTER_DEBUG_FORCE_KMS_MODE=simple to /etc/environment and reboot.

Revision history for this message
Sergey Zolotarev (szx) wrote :

1. Nope, the log is normal, nothing new is logged when moving the cursor around

2. Razer DeathAdder V2. BTW switching to 60 Hz doesn't seem to change anything. However, switching to an old cheap mouse decreases gnome-shell's CPU usage down to ~10%.

3. Unfortunately that didn't help. I also had this line in my /etc/environment before:

MUTTER_DEBUG_ENABLE_ATOMIC_KMS=0

Tried both with and without it.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks. And good catch, yes it should be MUTTER_DEBUG_ENABLE_ATOMIC_KMS=0 on 22.04

It sounds like the main issue is the input rate of the Razer DeathAdder V2 and gnome-shell's inefficient processing of a high event rate. You should be able to bring it under control with kernel parameter usbhid.mousepoll=2 (or 4 or 8). But this is still a gnome-shell performance bug.

summary: - gnome-shell high CPU utilization when moving mouse cursor
+ gnome-shell high CPU utilization when moving a high frequency mouse
Changed in gnome-shell (Ubuntu):
status: Incomplete → New
Revision history for this message
Sergey Zolotarev (szx) wrote :

Unfortunately, setting usbhid.mousepoll didn't for for my mouse, it keeps using 1000Hz for some reason, but thanks for your suggestion.

Revision history for this message
Sergey Zolotarev (szx) wrote (last edit ):

I've noticed that at some point gnome-shell starts consuming twice that amount of CPU resources when moving my mouse over the desktop, reaching nearly 100%, i.e. to the point where the desktop experience is not good. When this happens it goes from ~10% to 40-50% for the normal (125 Hz) mouse as well.

I'm not sure what it is that I do that triggers is. I've experienced this 2 or 3 times in the last week.

Revision history for this message
Sergey Zolotarev (szx) wrote :

perf report

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Great information, thanks.

Regarding usbhid.mousepoll=N having no effect, I forgot about bug 1625912.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-shell (Ubuntu):
status: New → Confirmed
Revision history for this message
Arnd (arnd-arndnet) wrote :

I've noticed high cpu usage of gnome-shell with a normal (125 Hz) Logitech ERGO M575 on ubuntu 22.04.

Just moving the mouse over the empty desktop will increase CPU usage of gnome-shell from single digit to up to 70%.

Changed in gnome-shell (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
Revision history for this message
Sergey Zolotarev (szx) wrote :

It seems to also track mouse movement when playing games in full-screen mode which reduces FPS. Is this normal?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

"Normal" or not, we want CPU usage to be lower so I will look into this bug in the next month or so.

Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

This is strange. I've been profiling gnome-shell 42 on jammy and gnome-shell 46 on noble. Neither have the bug, at least not with my lowly 1000Hz mice (which seems to be the same polling rate as the Razer DeathAdder V2).

The profile in comment #18 is intriguing because it very clearly shows meta_idle_manager_reset_idle_time is the problem for you. But when I profile my own systems, that function accounts for under 1% of gnome-shell's time.

Can you think of anything you have like an extension or application running that might seek to disable screensavers and prevent screen blanking? A browser or video player maybe?

Changed in gnome-shell (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

If you run 'sudo evtest', select the mouse and then wiggle it, what kind of output do you see?

Revision history for this message
Sergey Zolotarev (szx) wrote (last edit ):

To answer your first question: I'm testing on a freshly booted system with no applications running.

Regarding extensions:

After I disable the Desktop Icons NG extension (appears to be one of the built-ins), peak CPU usage for gnome-shell goes from ~55% to ~35% when moving over an empty desktop. When moving over an application such as gnome-terminal, CPU usage for gnome-shell increases to ~60% both with and without this extension (and also gnome-terminal itself consumes about 25%).

Besides that I have Ubuntu Dock and Ubuntu AppIndicators - disabling them didn't affect CPU usage.

evtest output attached.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks, yes I'm aware Desktop Icons NG is part of the problem here. I thought we already had a bug to track that but I can't find it so will include that here.

Changed in gnome-shell (Ubuntu):
status: Incomplete → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-shell (Ubuntu):
status: New → Confirmed
Changed in gnome-shell-extension-desktop-icons-ng (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.