How to find CPU usage in a specific part in a single application on linux?

43 views Asked by At

Have a problem, Gnome Shell use 90% of the CPU using a Ryzen 7, 128GB of ram & 2TB of .M2 WD Black with a AMD Radeon XFX 6800 XT. When I make the report in the bug tracker they tell me that it is not possible to replicate the problem, I have seen that many people have had the same problem but no one knows exactly why it occurs.

I would like to know how I can know in which part of the Gnome Shell application this excessive CPU usage, is there a way to break down the use of memory, disk and so on by monitoring functions or parts of a single application?

For example, from a WEB browser I can open the development tools and in the memory and performance tab I can know exactly which functions and parts use each percentage of cpu and memory, is there something similar for desktop applications in Linux?, whether by terminal or UI.

If I absolutely need to use debugging tools, how should I use them to detect this very common error?

1

There are 1 answers

0
Sean Wilson On

A good starting point is to install Bashtop or Bpytop (both by same creator). Check your distro's software repository and maybe check out a few different guides on installing. Nothing complicated, just see what options you have (i.e., from source, .deb/.rpm, Snap) and whether you want to use the developer's PPA or just use your distro repositories.

Once installed, you launch from the command line with (if you installed Bashtop):

bashtop

In your Processes window, you'll see a list of running processes. Off to the right hand side, you'll see 'reverse', 'tree' and a third argument.

Use your left/right arrow keys to scroll through the view arguments until you reach 'threads'.

Then, hit your 'e' key to enter Tree view:

e

Use your page up/page down keys to scroll down until you find your 'gnome-shell' process in the tree view (under 'systemd' in the included screenshot). Once it comes into view, use your up/down arrow keys to highlight the particular process running under it, and to move up or down the list.

You'll see the the memory and cpu usage, as well as green activity lines next to the 'Cpu' usage when a particular process is doing something. Use those down/up arrow keys to select the item you want more information on, then hit your 'enter' key.

You'll get a window showing more detailed information about the process. In the attached screenshot, it's the section with the 'language_server', '105795', 'terminate', 'kill', 'interrupt', 'close' in it and a vertical 'C M D' ...

I've included a screenshot of it running on one of my laptops, showing what it looks like when using Bashtop. In it, I've highlighted/selected the 'language-server' process running because I have my VSCode editor open. I can see in the detailed information pane that the particular item responsible for the 1.5 Mem% and 0.5 Cpu% usage is related to the Codeium extension I have installed in VSCode.

Bashtop/Bpytop are great for narrowing things down and finding basic usage information. To drill down further, you would need some profiling/testing applications, but this should at least help you zero in on things a bit. I hope this helps.

enter image description here