3

When my laptop gets slow for a moment during somewhat heavier processing I expect to see higher numbers (for CPU use) than what I in fact see in the conky Process Panel that I have on the desktop and in the System Monitor.

Using top in terminal I see numbers that justify that momentary slowness of the computer. For example, while Firefox is running with some addons that use relatively high CPU resources (displayed as "Web Content") the conky script (just like Gnome System Monitor) shows around 25% of CPU resources used, while top shows around 71%, which seems more "real" given the fact that the PC has indeed become slow.

enter image description here

How could I get those "real" numbers in the conky I use? And why is top different from that and from the System Monitor?

The part of the conky script that is significant here is this:

${top name 1} $alignr ${top cpu 1}%
${top name 2} $alignr ${top cpu 2}%
${top name 3} $alignr ${top cpu 3}%

etc.

4

This is because top is showing the value as a percentage of a single CPU core, while conky is showing the percentage of total available CPU power. If you run top and press I you should see the same (almost the same, there will always be a race condition: the time that top polls the CPU won't be the exact same time that conky does) numbers.

This is documented in man top (emphasis mine):

  1. %CPU -- CPU Usage

    The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.

    In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported. You toggle Threads mode with the `H' interactive command.

    Also for multi-processor environments, if Irix mode is Off, top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs. You toggle Irix/Solaris modes with the `I' interactive command.

So, what you are seeing in your example is that top is in Irix mode and reporting the %CPU value as a percentage of a single CPU, while conky is reporting it as a percentage of all available CPUs.

And, just to illustrate, this is what top looks like in Irix mode on my 8-core laptop when running pigz which can use multiple threads:

PID     USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ S COMMAND                                                               
1090509 terdon    20   0  657.6m   4.5m 605.3   0.0   0:33.18 R pigz                                                                  

See how the %CPU is well above 100? Now, the same thing in Solaris mode, shows:

PID     USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ S COMMAND                                                               
1100171 terdon    20   0  657.6m   4.5m  82.0   0.0   1:24.08 S pigz                                                                  

The numbers don't match exactly since I ran the command twice to get the output, but you should be able to see the genera idea.

10
  • You mention applications that can use multiple threads. Can Firefox? Can I tell if it does? Is it possible that it simply doesn't and that makes the Irix mode more "pertinent" in that case? I thought all or most application will used the 4 cores of my CPU. – cipricus Feb 25 '20 at 15:11
  • 1
    @cipricus I don't think firefox is parallelized, no. Why? These are just the defaults, they have nothing to do with the specific program. It's just that top is in Irix mode by default which is why you see the higher numbers. – terdon Feb 25 '20 at 15:12
  • As my CPU has 4 cores, am I wrong saying that Firefox using 70% CPU explains the machine getting slow, given that 3 CPU cores are free and therefore plenty of memory should be available? – cipricus Feb 25 '20 at 15:24
  • 1
    @cipricus the two are separate: you can have very high CPU usage with very low memory usage and vice versa. Usually, however, when your machine is slow it is because of high memory and not high CPU. I very much doubt that the CPU values you show would be making your machine slow. Have a look at the load values (in the top of the top output) and look at memory usage instead of CPU. Also look at I/O since that can also slow things down. On the whole, CPU is the least likely culprit here. – terdon Feb 25 '20 at 15:52
  • 3
    @cipricus the processor is very unlikely to cause your machine to be slow. Look at RAM, yes, and disk read/write, one of those will be the issue. – terdon Feb 25 '20 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.