Ubuntu – Single CPU always at 100%, lagging | Ubuntu 18.04.4

18.04cpu

I bought a new Laptop which was running fine for about one or two weeks. I can't exactly recall a certain trigger but I now have the problem that one CPU core is almost always running near 100% and the computer is lagging.

I use a dual boot from the beginning on, Windows 10 however is running fine.

Specs:

Ubuntu 18.04.4 LTS

Intel(R) Core(TM) i7-8565U

GeForce GTX 1050 Ti Mobile

16GB RAM

I looked at some other posts but the suggested fixes didn't work for me so far.
I made sure the computer uses the NVidia Graphics Card and to my best knowledge newest drivers are installed. I also tried switching to Kubuntu Desktop but the problem remained.

My main problem is, that I can't find the process which is causing the permanent CPU usage.
I restarted the computer and let it sit idle for a few minutes, occasionally the CPU usage went down but usually it stays high. (See 2 attached picture)

When I run any other program as well the lagging gets worse, playing a youtube video makes the mouse itself lag heavily and the CPU is almost running at 100% constantly (See picture)

I am thankful for any help and will gladly provide any data / output from commands that are needed, since I want to fix this issue.

Thank you very much

EDIT:
The output of

ps aux --sort=-pcpu | head

is

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      1602 15.0  0.7 576228 129056 tty2    Sl+  10:24   6:20 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3
lars      5880 13.5  2.2 3817104 365864 tty2   Sl+  10:46   2:47 /usr/lib/firefox/firefox -new-window
lars      1780 12.4  2.9 4400160 486128 tty2   Rl+  10:24   5:13 /usr/bin/gnome-shell
lars      6139 10.0  1.2 2760008 209576 tty2   Sl+  10:47   2:00 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -prefsLen 7500 -prefMapSize 217531 -parentBuildID 20200403170909 -appdir /usr/lib/firefox/browser 5880 true tab
lars      2159  5.4  0.2 656356 47904 tty2     Sl+  10:24   2:16 gnome-system-monitor
lars      6776  4.7  1.0 2663220 170720 tty2   Sl+  11:02   0:13 /usr/lib/firefox/firefox -contentproc -childID 13 -isForBrowser -prefsLen 7823 -prefMapSize 217531 -parentBuildID 20200403170909 -appdir /usr/lib/firefox/browser 5880 true tab
root      1386  2.2  0.0      0     0 ?        S    10:24   0:56 [irq/152-nvidia]
lars      6730  1.2  1.2 2710580 202384 tty2   Sl+  11:01   0:04 /usr/lib/firefox/firefox -contentproc -childID 12 -isForBrowser -prefsLen 7752 -prefMapSize 217531 -parentBuildID 20200403170909 -appdir /usr/lib/firefox/browser 5880 true tab
lars      6003  1.0  1.1 34232032 191064 tty2  Sl+  10:46   0:13 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 6684 -prefMapSize 217531 -parentBuildID 20200403170909 -appdir /usr/lib/firefox/browser 5880 true tab

I tried unplugging all USB devices but it didn't change anything

EDIT2:

Pictures of htop after fresh install:
Xorg
gnome-shell

EDIT3:
Output of pstree -l

systemd─┬─ModemManager───2*[{ModemManager}]
        ├─NetworkManager─┬─dhclient
        │                └─2*[{NetworkManager}]
        ├─accounts-daemon───2*[{accounts-daemon}]
        ├─acpid
        ├─anacron
        ├─avahi-daemon───avahi-daemon
        ├─bluetoothd
        ├─boltd───2*[{boltd}]
        ├─colord───2*[{colord}]
        ├─cron
        ├─cups-browsed───2*[{cups-browsed}]
        ├─cupsd
        ├─dbus-daemon
        ├─deja-dup-monito───3*[{deja-dup-monito}]
        ├─gdm3─┬─gdm-session-wor─┬─gdm-wayland-ses─┬─gnome-session-b─┬─gnome-shell─┬─Xwayland───9*[{Xwayland}]
        │      │                 │                 │                 │             ├─ibus-daemon─┬─ibus-dconf───3*[{ibus-dconf}]
        │      │                 │                 │                 │             │             ├─ibus-engine-sim───2*[{ibus-engine-sim}]
        │      │                 │                 │                 │             │             └─2*[{ibus-daemon}]
        │      │                 │                 │                 │             └─26*[{gnome-shell}]
        │      │                 │                 │                 ├─gsd-a11y-settin───3*[{gsd-a11y-settin}]
        │      │                 │                 │                 ├─gsd-clipboard───3*[{gsd-clipboard}]
        │      │                 │                 │                 ├─gsd-color───4*[{gsd-color}]
        │      │                 │                 │                 ├─gsd-datetime───2*[{gsd-datetime}]
        │      │                 │                 │                 ├─gsd-housekeepin───2*[{gsd-housekeepin}]
        │      │                 │                 │                 ├─gsd-keyboard───4*[{gsd-keyboard}]
        │      │                 │                 │                 ├─gsd-media-keys───4*[{gsd-media-keys}]
        │      │                 │                 │                 ├─gsd-mouse───2*[{gsd-mouse}]
        │      │                 │                 │                 ├─gsd-power───4*[{gsd-power}]
        │      │                 │                 │                 ├─gsd-print-notif───2*[{gsd-print-notif}]
        │      │                 │                 │                 ├─gsd-rfkill───2*[{gsd-rfkill}]
        │      │                 │                 │                 ├─gsd-screensaver───2*[{gsd-screensaver}]
        │      │                 │                 │                 ├─gsd-sharing───3*[{gsd-sharing}]
        │      │                 │                 │                 ├─gsd-smartcard───4*[{gsd-smartcard}]
        │      │                 │                 │                 ├─gsd-sound───3*[{gsd-sound}]
        │      │                 │                 │                 ├─gsd-wacom───3*[{gsd-wacom}]
        │      │                 │                 │                 ├─gsd-xsettings───4*[{gsd-xsettings}]
        │      │                 │                 │                 └─3*[{gnome-session-b}]
        │      │                 │                 └─2*[{gdm-wayland-ses}]
        │      │                 └─2*[{gdm-session-wor}]
        │      ├─gdm-session-wor─┬─gdm-x-session─┬─Xorg───2*[{Xorg}]
        │      │                 │               ├─lxsession─┬─lxpanel─┬─firefox─┬─RDD Process───3*[{RDD Process}]
        │      │                 │               │           │         │         ├─2*[Web Content───33*[{Web Content}]]
        │      │                 │               │           │         │         ├─Web Content───35*[{Web Content}]
        │      │                 │               │           │         │         ├─4*[Web Content───34*[{Web Content}]]
        │      │                 │               │           │         │         ├─Web Content───47*[{Web Content}]
        │      │                 │               │           │         │         ├─WebExtensions───29*[{WebExtensions}]
        │      │                 │               │           │         │         └─85*[{firefox}]
        │      │                 │               │           │         └─4*[{lxpanel}]
        │      │                 │               │           ├─lxpolkit───2*[{lxpolkit}]
        │      │                 │               │           ├─openbox───2*[{openbox}]
        │      │                 │               │           ├─pcmanfm───2*[{pcmanfm}]
        │      │                 │               │           ├─ssh-agent
        │      │                 │               │           └─2*[{lxsession}]
        │      │                 │               └─2*[{gdm-x-session}]
        │      │                 └─2*[{gdm-session-wor}]
        │      └─2*[{gdm3}]
        ├─ibus-x11───3*[{ibus-x11}]
        ├─irqbalance───{irqbalance}
        ├─2*[kerneloops]
        ├─menu-cached───2*[{menu-cached}]
        ├─networkd-dispat───{networkd-dispat}
        ├─nm-applet───3*[{nm-applet}]
        ├─nvidia-persiste
        ├─packagekitd───2*[{packagekitd}]
        ├─polkitd───2*[{polkitd}]
        ├─pulseaudio───2*[{pulseaudio}]
        ├─rsyslogd───3*[{rsyslogd}]
        ├─rtkit-daemon───2*[{rtkit-daemon}]
        ├─snapd───17*[{snapd}]
        ├─ssh-agent
        ├─systemd─┬─(sd-pam)
        │         ├─at-spi-bus-laun─┬─dbus-daemon
        │         │                 └─3*[{at-spi-bus-laun}]
        │         ├─at-spi2-registr───2*[{at-spi2-registr}]
        │         ├─dbus-daemon
        │         ├─ibus-portal───2*[{ibus-portal}]
        │         ├─pulseaudio───2*[{pulseaudio}]
        │         └─xdg-permission-───2*[{xdg-permission-}]
        ├─systemd─┬─(sd-pam)
        │         ├─at-spi-bus-laun─┬─dbus-daemon
        │         │                 └─3*[{at-spi-bus-laun}]
        │         ├─at-spi2-registr───2*[{at-spi2-registr}]
        │         ├─dbus-daemon
        │         ├─dconf-service───2*[{dconf-service}]
        │         ├─gnome-screensav───3*[{gnome-screensav}]
        │         ├─gnome-terminal-─┬─bash───htop
        │         │                 ├─bash───pstree
        │         │                 └─4*[{gnome-terminal-}]
        │         ├─goa-daemon───3*[{goa-daemon}]
        │         ├─goa-identity-se───3*[{goa-identity-se}]
        │         ├─gvfs-afc-volume───3*[{gvfs-afc-volume}]
        │         ├─gvfs-goa-volume───2*[{gvfs-goa-volume}]
        │         ├─gvfs-gphoto2-vo───2*[{gvfs-gphoto2-vo}]
        │         ├─gvfs-mtp-volume───2*[{gvfs-mtp-volume}]
        │         ├─gvfs-udisks2-vo───2*[{gvfs-udisks2-vo}]
        │         ├─gvfsd─┬─gvfsd-trash───2*[{gvfsd-trash}]
        │         │       └─2*[{gvfsd}]
        │         ├─gvfsd-fuse───5*[{gvfsd-fuse}]
        │         ├─indicator-appli───2*[{indicator-appli}]
        │         ├─indicator-sound───3*[{indicator-sound}]
        │         ├─xdg-desktop-por───4*[{xdg-desktop-por}]
        │         ├─xdg-desktop-por───2*[{xdg-desktop-por}]
        │         ├─xdg-document-po───5*[{xdg-document-po}]
        │         ├─xdg-permission-───2*[{xdg-permission-}]
        │         ├─xfce4-notifyd───2*[{xfce4-notifyd}]
        │         └─xfconfd
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-resolve
        ├─systemd-timesyn───{systemd-timesyn}
        ├─systemd-udevd
        ├─thermald───{thermald}
        ├─udisksd───4*[{udisksd}]
        ├─unattended-upgr───{unattended-upgr}
        ├─update-notifier───3*[{update-notifier}]
        ├─upowerd───2*[{upowerd}]
        ├─whoopsie───2*[{whoopsie}]
        ├─wpa_supplicant
        └─xfce4-power-man───2*[{xfce4-power-man}]

EDIT: usage with ubuntu on wayland
Htop on Ubuntut on Wayland

Output of journalctl -f

-- Logs begin at Thu 2020-04-16 14:32:57 CEST. --
Apr 16 18:03:57 yoshua systemd[1]: Starting Hostname Service...
Apr 16 18:03:57 yoshua dbus-daemon[885]: [system] Successfully activated service 'org.freedesktop.hostname1'
Apr 16 18:03:57 yoshua systemd[1]: Started Hostname Service.
Apr 16 18:03:57 yoshua nautilus[2465]: Called "net usershare info" but it failed: Failed to execute child process “net” (No such file or directory)
Apr 16 18:04:06 yoshua eog[2493]: Failed to open file '/home/lars/.cache/thumbnails/normal/bd89ad6e4e39e613a580a0a13dc30c75.png': No such file or directory
Apr 16 18:04:16 yoshua org.gnome.Shell.desktop[1512]: libinput error: client bug: timer event11 debounce: offset negative (-234ms)
Apr 16 18:04:16 yoshua org.gnome.Shell.desktop[1512]: libinput error: client bug: timer event11 debounce: offset negative (-170ms)
Apr 16 18:04:16 yoshua org.gnome.Shell.desktop[1512]: libinput error: client bug: timer event11 debounce short: offset negative (-183ms)
Apr 16 18:04:20 yoshua org.gnome.Shell.desktop[1512]: libinput error: client bug: timer event11 debounce: offset negative (-1ms)
Apr 16 18:04:20 yoshua org.gnome.Shell.desktop[1512]: libinput error: client bug: timer event11 debounce short: offset negative (-15ms)
Apr 16 18:05:55 yoshua dbus-daemon[885]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.121' (uid=1000 pid=2149 comm="/usr/lib/firefox/firefox -new-window " label="unconfined")
Apr 16 18:05:55 yoshua systemd[1]: Starting Hostname Service...
Apr 16 18:05:55 yoshua dbus-daemon[885]: [system] Successfully activated service 'org.freedesktop.hostname1'
Apr 16 18:05:55 yoshua systemd[1]: Started Hostname Service.
Apr 16 18:05:55 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:05:56 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:05:57 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:05:58 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:05:59 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:05:59 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:06:00 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:06:00 yoshua gvfsd[1528]: mkdir failed on directory /var/cache/samba: Permission denied
Apr 16 18:06:10 yoshua kernel: [drm:intel_pipe_update_end [i915]] *ERROR* Atomic update failure on pipe A (start=22662 end=22663) time 111 us, min 1073, max 1079, scanline start 1072, end 1080
Apr 16 18:06:13 yoshua kernel: [drm:intel_pipe_update_end [i915]] *ERROR* Atomic update failure on pipe A (start=22830 end=22831) time 357 us, min 1073, max 1079, scanline start 1072, end 1096
Apr 16 18:06:45 yoshua kernel: [drm:intel_pipe_update_end [i915]] *ERROR* Atomic update failure on pipe A (start=24753 end=24754) time 239 us, min 1073, max 1079, scanline start 1066, end 1079
Apr 16 18:06:51 yoshua gnome-shell[1512]: Some code accessed the property 'WindowPreviewMenu' on the module 'windowPreview'. That property was defined with 'let' or 'const' inside the module. This was previously supported, but is not correct according to the ES6 standard. Any symbols to be exported from a module must be defined with 'var'. The property access will work as previously for the time being, but please fix your code anyway.

EDIT:
It is working fine now. No more peaks from one core, all are continuously working on a small level. The last thing I did was what @Gryu recommended:
I switched into tty. Switched to lightdm sudo dpkg-reconfigure lightdm which didn't change anything. I restarted and switched back to gdm3 via the same command.

I don't understand how this helped, but I am happy.
Thanks you very much!

EDIT:
The way I see it, I can avoid the problem if I shutdown using the physical power-off button. I don't know what to think about it, I just leave the info here.

Best Answer

You could try one or few of:

  • Use htop to see what processes load your system and kill them to see what will happen: killall processname or killall -9 processname to kill it forcefully.
  • Reinstall a package of a program or command that loads it intensively by: sudo apt purge package_name && sudo apt autoremove && sudo apt install package_name
  • Update/Install CPU mocrocode firmware: sudo apt update && sudo apt install intel-microcode microcode.ctl
  • Install a different kernel and try it
  • Install a different desktop manager: gdm3 instead of lightdm or vice versa, purging previous: sudo apt install gdm3 && sudo apt purge lightdm
  • Install a different desktop environment: sudo apt install lubuntu-desktop and try it.
  • Purge xubuntu-desktop or xfce4 as I was noticing that system lags when it is installed, however, not used: sudo apt purge xubuntu-desktop && sudo apt purge xfce*

My pstree -l on 19.10 with gdm3:

├─gdm3─┬─gdm-session-wor─┬─gdm-x-session─┬─Xorg───{Xorg}
│      │                 │               ├─gnome-session-b───3*[{gnome-session-b}]
│      │                 │               └─2*[{gdm-x-session}]
│      │                 └─2*[{gdm-session-wor}]
│      ├─gdm-session-wor─┬─gdm-x-session─┬─Xorg───{Xorg}
│      │                 │               ├─gnome-session-b─┬─ssh-agent
│      │                 │               │                 └─2*[{gnome-session-b}]
│      │                 │               └─2*[{gdm-x-session}]
│      │                 └─2*[{gdm-session-wor}]
│      └─2*[{gdm3}]

My pstree -l on 18.04 VM:

├─lightdm─┬─Xorg───5*[{Xorg}]
│         ├─lightdm─┬─lxsession─┬─lxpanel─┬─lxterminal─┬─bash───pstree
│         │         │           │         │            ├─bash
│         │         │           │         │            └─2*[{lxterminal}]
│         │         │           │         └─4*[{lxpanel}]
│         │         │           ├─lxpolkit───2*[{lxpolkit}]
│         │         │           ├─openbox───2*[{openbox}]
│         │         │           ├─pcmanfm───2*[{pcmanfm}]
│         │         │           ├─ssh-agent
│         │         │           └─2*[{lxsession}]
│         │         └─2*[{lightdm}]
│         └─2*[{lightdm}]

Run also journalctl -f in a terminal to see what happens. Maybe some gnome-settings-daemon (gsd) constantly trying to do something and fails throwing errors and it takes the whole core.

Switch to lightdm to see if something will be changed, but do it on some tty: Alt+Ctrl+F3: sudo apt purge gdm3 && sudo apt install lightdm. You could also do it without gdm3 removing: sudo dpkg-reconfigure lightdm if you have it installed.

sudo dpkg-reconfigure lightdm
reboot
sudo dpkg-reconfigure gdm3

Maybe switching to lightdm fourth and to gdm3 back somehow changes gdm3 configuration modified previously by different graphical configuration tools.

Related Question