Ubuntu – Ubuntu 20.04 gnome-shell continual 20% CPU usage

20.04gnome-shell

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                                                                                   

Best Answer

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.

Related Question