19

Just upgraded to ubuntu 20.04 gnome-shell is sitting continually at around 20% CPU usage.

Any help? some details below:

top - 15:01:14 up 48 min,  1 user,  load average: 0.16, 0.63, 0.76
Tasks: 397 total,   1 running, 396 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.2 us,  0.3 sy,  0.0 ni, 97.3 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :  32015.4 total,  17153.7 free,   2707.2 used,  12154.5 buff/cache
MiB Swap:  32668.0 total,  32668.0 free,      0.0 used.  28748.7 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                   
   2709 alan      20   0 4588528 550700 124664 S  21.2   1.7   8:55.91 gnome-shell

Looking at what it is doing it seems to spend most time stat-ing files that dont exist:

strace -C -p 2709

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 54.40    0.233348           2     95108     90024 stat
 10.72    0.045978           3     12340     10326 recvmsg
  7.39    0.031684           4      7780           getpid
  7.20    0.030878           5      5875           poll
  3.84    0.016474           5      2796           writev
  3.38    0.014505          15       942           ioctl
  2.53    0.010840           2      4340      1550 openat
  1.89    0.008100           2      3100           getdents64
  1.81    0.007768           3      2198           read
  1.33    0.005718           1      2869           close
  1.32    0.005682           4      1301        90 futex
  1.17    0.005004           1      2790           fstat
  1.01    0.004339           3      1244           sched_yield
  0.63    0.002720           5       538           write
  0.58    0.002469           3       764           mprotect
  0.43    0.001845           3       511           mmap
  0.36    0.001540           2       640           munmap
  0.00    0.000021           4         5           recvfrom
  0.00    0.000013           1        11           clock_nanosleep
  0.00    0.000003           3         1           restart_syscall
  0.00    0.000001           0         4           getrusage
------ ----------- ----------- --------- --------- ----------------
100.00    0.428930                145157    101990 total

And some output from strace (edited):

...
stat("/home/alan/.local/share/icons/hicolor/16x16@2/apps", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/apps", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/categories", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/devices", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/emblems", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emotes", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16/emotes", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
stat("/home/alan/.local/share/icons/hicolor/16x16@2/emotes", 0x7ffc14b2b2f0) = -1 ENOENT (No such file or directory)
...
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
getpid()                                = 2709
ioctl(12, _IOC(_IOC_READ|_IOC_WRITE, 0x46, 0x2a, 0x20), 0x7ffc14b2d780) = 0
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\31\0\v\0\367\212\240\2\0\0\0\0! \0\0\367\212\240\2\336\1\0\0006\r\0\0\0\0\0\0"..., iov_len=44}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 44
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\206\20\2\0.\0\340\0\206\t\5\0000\0\340\0\4\0\0\0\0\0\0\0\236\3\0\0\206\3\4\0"..., iov_len=44}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 44
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="T\1&\0360\0\340\0\0\0\0\0\236\3\0\0\0\0\0\0\236\3\0\0:\t#\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=27, events=POLLIN}, {fd=28, events=POLLIN}, {fd=29, events=POLLIN}, {fd=31, events=POLLIN}, {fd=32, events=POLLIN}, {fd=34, events=POLLIN}, {fd=35, events=POLLIN}, {fd=41, events=POLLIN}, {fd=46, events=POLLIN}, {fd=50, events=POLLIN}, {fd=88, events=POLLIN}], 13, 0) = 0 (Timeout)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\31\0\v\0\367\212\240\2\0\0\0\0! \0\0\367\212\240\2\337\1\0\0006\r\0\0\0\0\0\0"..., iov_len=44}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 44
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=27, events=POLLIN}, {fd=28, events=POLLIN}, {fd=29, events=POLLIN}, {fd=31, events=POLLIN}, {fd=32, events=POLLIN}, {fd=34, events=POLLIN}, {fd=35, events=POLLIN}, {fd=41, events=POLLIN}, {fd=46, events=POLLIN}, {fd=50, events=POLLIN}, {fd=88, events=POLLIN}], 13, 74) = 1 ([{fd=31, revents=POLLIN}])
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0'\36\367\212\240\2\241\1\0\0<\t#\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 64
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\24\0\6\0\367\212\240\2\241\1\0\0\6\0\0\0\0\0\0\0\377\377\377\377", iov_len=24}], 1) = 24
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="+\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
poll([{fd=31, events=POLLIN}], 1, -1)   = 1 ([{fd=31, revents=POLLIN}])
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="T\1'\36\377\t\340\0\0\0\0\0007\r\0\0\0\0\0\0007\r\0\0?\t#\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 176
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\201\10\3\0\367\212\240\2\2\0\0\0", iov_len=12}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 12
poll([{fd=31, events=POLLIN}], 1, -1)   = 1 ([{fd=31, revents=POLLIN}])
recvmsg(31, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\3*\36\2\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 40
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
poll([{fd=31, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=31, revents=POLLOUT}])
writev(31, [{iov_base="\217\3\4\0\0\n\340\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 16
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(5, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(31, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)

extension data that was requested:

alan@server:~ -[] $ ls -al ~/.local/share/gnome-shell/extensions
total 12
drwxrwxr-x 3 alan alan 4096 May 25  2019 .
drwx------ 3 alan alan 4096 Jun 23 17:10 ..
drwxrwxr-x 3 alan alan 4096 May 25  2019 workspace-grid@mathematical.coffee.gmail.com
alan@server:~ -[] $ ls -al /usr/share/gnome-shell/extensions
total 20
drwxr-xr-x 5 root root 4096 Jun 17 18:38 .
drwxr-xr-x 7 root root 4096 Jun 17 18:39 ..
drwxr-xr-x 2 root root 4096 Jun 17 18:38 desktop-icons@csoriano
drwxr-xr-x 3 root root 4096 Jun 17 18:36 ubuntu-appindicators@ubuntu.com
drwxr-xr-x 3 root root 4096 Jun 17 18:36 ubuntu-dock@ubuntu.com

and complete top (snapshot)

Tasks: 405 total,   1 running, 404 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.5 us,  0.4 sy,  0.0 ni, 96.8 id,  0.1 wa,  0.0 hi,  0.2 si,  0.0 st
MiB Mem :  32015.4 total,  16744.1 free,   3038.5 used,  12232.8 buff/cache
MiB Swap:  32668.0 total,  32668.0 free,      0.0 used.  28377.6 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                       
   2709 alan      20   0 4596140 562652 135088 S  20.9   1.7  33:46.03 gnome-shell                                                                                   
   9822 alan      20   0 4735696 201332  96160 S   3.3   0.6   8:56.20 chrome                                                                                        
   9839 alan      20   0 4793876 197464  89324 S   3.3   0.6   6:19.33 chrome                                                                                        
   2497 root      20   0  197440  68520  47796 S   2.7   0.2   1:43.00 Xorg                                                                                          
   3213 alan      20   0  966064  58144  39524 S   2.3   0.2   1:24.41 gnome-terminal-                                                                               
   9732 alan      20   0 4794584 167996  87708 S   2.3   0.5   4:12.00 chrome                                                                                        
   2973 alan      20   0  417144  31224  24820 S   2.0   0.1   3:49.59 indicator-multi                                                                               
  11800 alan      20   0 4688644 136292  87092 S   1.7   0.4   2:21.77 chrome                                                                                        
   6196 alan      20   0  784460 261128 132512 S   1.3   0.8   3:20.76 chrome                                                                                        
   1434 root     -51   0       0      0      0 S   0.7   0.0   0:51.84 irq/50-nvidia                                                                                 
   6236 alan      20   0  896856 255080  91376 S   0.7   0.8   5:10.00 chrome                                                                                        
      1 root      20   0  168276  12092   8272 S   0.3   0.0   0:03.31 systemd                                                                                       
   1100 systemd+  20   0   24576  13672   9252 S   0.3   0.0   0:01.81 systemd-resolve                                                                               
   1436 root      20   0       0      0      0 S   0.3   0.0   0:08.46 nv_queue                                                                                      
   2411 alan      20   0    9356   6668   4192 S   0.3   0.0   0:32.45 dbus-daemon                                                                                   
   2972 alan      20   0  454696  33432  27780 S   0.3   0.1   0:44.40 indicator-netsp                                                                               
   3030 alan      20   0 7109676 247340  82260 S   0.3   0.8   0:24.37 dropbox                                                                                       
   6238 alan      20   0  356452  97728  66520 S   0.3   0.3   0:37.41 chrome                                                                                        
  11691 root      20   0       0      0      0 I   0.3   0.0   0:00.19 kworker/10:0-events                                                                           
  11832 alan      20   0 4626144 103308  73416 S   0.3   0.3   0:07.15 chrome                                                                                        
  15438 alan      20   0   12396   4344   3396 R   0.3   0.0   0:00.06 top                                                                                           
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd                                                                                      
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                                                                        
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp                                                                                    
      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-kblockd                                                                          
      9 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq                                                                                  
     10 root      20   0       0      0      0 S   0.0   0.0   0:00.26 ksoftirqd/0                                                                                   
     11 root      20   0       0      0      0 I   0.0   0.0   0:07.61 rcu_sched                                                                                     
     12 root      rt   0       0      0      0 S   0.0   0.0   0:00.04 migration/0                                                                                   
     13 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/0                                                                                 
     14 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0                                                                                       
     15 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/1                                                                                       
     16 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/1                                                                                 
     17 root      rt   0       0      0      0 S   0.0   0.0   0:00.25 migration/1                                                                                   
     18 root      20   0       0      0      0 S   0.0   0.0   0:00.09 ksoftirqd/1                                                                                   
     20 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/1:0H-kblockd                                                                          
     21 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/2                                                                                       
     22 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/2                                                                                 
     23 root      rt   0       0      0      0 S   0.0   0.0   0:00.25 migration/2                                                                                   
alpatters
  • 191
  • 1
  • 1
  • 4
  • Can you please see through the output of **lsof -p GNOME_PID** to figure out what is opened as file descriptor **31** and **5** ? – Parsa Mousavi Jun 23 '20 at 14:37
  • gnome-she 2709 alan 5u unix 0x0000000000000000 0t0 40877 type=STREAM gnome-she 2709 alan 31u unix 0x0000000000000000 0t0 44655 type=STREAM – alpatters Jun 23 '20 at 14:49
  • @ParsaMousavi what are you looking to find specifically and why those two FDs. It looks like they are both streams – alpatters Jun 23 '20 at 15:01
  • **Stat** syscall is for gathering the metadata about a file and recvmsg is for receiving messages from a socket.Looks like the Gnome-Shell is continuously looking for some icons and wants to receive messages from a socket.I don't know why.I hoped to find out which file or socket the gnome-shell is trying to receive from. – Parsa Mousavi Jun 23 '20 at 15:07
  • Ah ok, not sure how to find out the other end of the socket. Also the stat calls are all for files that don't exist, of which there are a lot of calls for. – alpatters Jun 23 '20 at 15:17
  • Probably a GNOME Shell extension problem. Edit your question and show me `ls -al ~/.local/share/gnome-shell/extensions` and `ls -al /usr/share/gnome-shell/extensions`. Also show me a complete screenshot of `top`. – heynnema Jun 23 '20 at 16:40
  • added the output you requested – alpatters Jun 23 '20 at 16:58
  • Make sure to start comments to me with @heynnema or I'll miss them. You're doing good with the gnome-shell extensions. However, the `top` command output shows at least two `indicator-*` applications that might cause your gnome-shell CPU% to be higher than 3%. Disable ALL gnome-shell extensions, and the `indicator-*` apps, and see if gnome-shell looks better. Report back. – heynnema Jun 24 '20 at 18:01
  • from a developer point of view, having so many errors sucks. Most of them are not really errors. They were simply not captured properly. – Carlos Pinzón Sep 06 '20 at 19:17
  • I also see this from time to time - very frustrating. I just kill the process - after a couple of seconds it restarts and all is fine. – Fanus Johnson Nov 16 '20 at 12:04
  • @alpatters I have replaced `gdm3` with `lightdm`, the CPU and memory usage has been reduced. – Bilal Oct 11 '21 at 05:49
  • For me it was video files saved in Desktop folder. gnome-shell was busy creating thumbnails for those. – alex Nov 17 '21 at 12:42

5 Answers5

10

Just in case anybody has a similar issue, I had CPU usage of 80% consistently from GNOME Shell and I switched the various extensions off for testing, on version 20.04.

It turned out I had the performance monitor in the top right hand side bar (system load monitor) - once that was quit, everything was back to normal. If anybody has any suggestions how to diagnose why I'm happy to test.

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
dannyhudders
  • 101
  • 1
  • 3
  • @dannyhudders thanks for that, I did have the system perf monitor on the top bar. I actually switched to XFCE which doesn't have this problem. But I'll check on gnome again. – alpatters Aug 26 '20 at 08:44
  • 1
    This was also my case. I had both the network monitor and activity monitor running in the top bar. Together they were using 20% CPU. – alpatters Sep 02 '20 at 14:23
  • 1
    Just quit `system load indicator` – fuat Nov 10 '20 at 09:01
  • 2
    The irony that your system load monitor put load on the system! – Stewart Mar 29 '21 at 08:12
  • I ran `sudo apt-get remove gnome-system-monitor` and the load disappeared! I also had to reboot my VM because it did not properly remove the actual load indicators from the gnome-shell (as the bar is called). – Alexis Wilke Sep 09 '22 at 17:58
3

This seems to be a big issue, I don't have any extensions loaded and it takes 40% CPU on idle.

enter image description here

However I disabled Wayland and it went to less than 1%.

enter image description here

I disabled it using this: https://askubuntu.com/a/968265/78252

If you wish to do it permanently, edit

/etc/gdm3/custom.conf and uncomment the line

#WaylandEnable=false by removing the # in front.

Save the file and then on reboot you will never see the cog asking for which session to use.

  • 1
    This did not at all change gnome-shell's high CPU usage on my 20.04 system. – Lexible Feb 21 '21 at 04:33
  • 1
    Try disabling all extensions and enable them back slowly 1 by 1 while checking the resources. – Vladimir Hidalgo Feb 22 '21 at 02:25
  • 1
    Thank you, Vladimir Hildago... that is a really useful tip for a newb like me. :) – Lexible Feb 22 '21 at 16:00
  • I had the exact same problem with the same percentage when IDLE. Interestingly the IDLE load was 40% when the system was on battery and the IDLE load was 10% when it was plugged in. Now it is 0% :) Also the whole system feels faster. – Karussell Sep 19 '22 at 21:21
  • Today it was back at 15% regardless of whether it was plugged in or not. After restart the IDLE usage of gnome-shell is still over 5% ... what a mess. – Karussell Sep 22 '22 at 07:47
2

I had a similar issue and solved it by using the tweaks program and disabling animations.

This reduced the load at idle from a constant 60% to nothing.

johannesack
  • 121
  • 3
0

After trying these solutions with no hope.I cleaned my busy desktop of 100+ files (and leave only 3 files left).

CPU used by gnome-shell instantly reduced from 40% to 15%

RyanN
  • 1
0

A similar problem led me here. I found that having the Bluetooth settings window open in the background, with the Bluetooth radio ON, keeps gnome-shell around 40% CPU time, +/- 5% for me. Pairing something does not change the CPU usage, so this does not seem to be the result of constant scanning. Closing the settings window or changing to something other than Bluetooth, like WiFi or Mouse settings drops the CPU usage to around 0% right away.

zerpsed
  • 101
  • 1