After running Ubuntu 18.04 for some days without logging out, things has started to get slower and slower. When I try to switch windows, it can take 5-10 seconds before anything happens. The same when trying to activate a window or text field for giving keyboard input. I opened a terminal window and ran top
and watched the output for some minutes. In general, three processes stays on the top of the list: 1) gnome-shell (8% cpu), 2) chrome (6% cpu), and 3) Xorg (4% cpu):
These number does not change very much (± 1% ) while I am watching.
I did not have this problem in 17.04, however it appeared in 17.10, but only for the first few weeks I think. Then suddenly everything worked as normal. But now after upgrading to 18.04, the problem has returned.
See also Ubuntu 17.10 tons of lags with mouse and window glitch
I stumbled upon the command
ubuntu-drivers autoinstall
. Seems it may have been the problem with nvidia drivers in my case, after that the gnome-shell cpu behavior was back to normal