3

I am a big fan of gnome-shell extensions, except for the problem of tracking high CPU usage.

I run a lot of background scripts related to server management, therefore constantly constantly logging in / out in order to locate which shell extension(s) has suddenly started consuming massive amounts of CPU is, inconvenient.

My Problem: gnome-shell is consuming ~100% regularly.. I can use cpulimit to temporarily put a leash on it, but av playback gets choppy.

Does any know a more efficient method of locating the problematic extension?

thanks

  • Maybe a simpler method exist, but for i in $(pgrep -f "gnome-shell"); do echo "Tracing process: $i"; sudo timeout 10 strace -c -p "$i"; done should give you and idea(within 10 seconds windoe) of what the running gnome-shell process/s exactly doing ... You can even attache to and debug running processes using other methods e.g. https://askubuntu.com/a/1419821/968501 – Raffa Aug 13 '22 at 09:47
  • @Raffa thanks for that.. maybe one day I will comprehend the output.. :-) – nightwatch Aug 13 '22 at 11:09
  • Alright :-) ... Answer added with another straight forward method ... I hope it helps. – Raffa Aug 14 '22 at 11:20

1 Answers1

2

To test the behavior of newly enabled gnome extensions and how they might affect your CPU usage without needing to log out, you can run a new gnome-shell nested(in a window) like so:

dbus-run-session gnome-shell --nested

You can set the window size with the environment variable MUTTER_DEBUG_DUMMY_MODE_SPECS like so(e.g. window size 1636x800):

MUTTER_DEBUG_DUMMY_MODE_SPECS=1636x800

and use it like so:

MUTTER_DEBUG_DUMMY_MODE_SPECS=1636x800 dbus-run-session gnome-shell --nested

Extra information available at man gnome-shell and man dbus-run-session

The output from that session will also be printed in the parent terminal window for tracing/debugging.

On the other hand(a bit more advanced though), you can use strace to trace what system calls/signals are being used by/for the running gnome-shell process/s and e.g. print a 10 second summary like so:

for i in $(pgrep -f "gnome-shell")
do
    echo "Tracing process: $i"
    sudo timeout 10 strace -c -p "$i" # administrator privileged account needed for strace to attache to running services
done

You can also attach to and debug running processes using other methods ... Some of which are discussed in this answer.

Raffa
  • 32,237