Score:-4

Understanding top command output

fj flag

Below is screenshot of top command output.

enter image description here

I want to understand memory and cpu information in this top's summary view. I have following doubts:

  1. Are the numbers for us, sy, ni etc in %Cpu(s) in third line are percentages of total hardware CPU processing power available? (I believe this is likely the case as I am unable to imaging anything else out of which % is shown.)

    MAN page says:

    Line 2 shows CPU state percentages based on the interval since the last refresh. As a default, percentages for these individual categories are displayed.

    SO, I believe this indeed mean "percentages of total hardware CPU processing power available", right?

  2. What are the values in %CPU column? Is it percentages of total hardware CPU processing power available or percentage of current CPU utilisation, that is percentage of %Cpu(s) specified in third row? (I feel later, because total of value in %CPU column is greater than total of us, sy and ni values (which actually contributes to current CPU utilisation, if am not wrong.).

    MAN page says:

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

    Its not clear share out of "total hardware CPU processing power" or "current CPU utilization".

    MAN page says:

    A task's currently used share of available physical memory.

    Again not clear whether its share out of "total RAM available" or "current memory utilization".

  3. What are the values in %MEM column? Is it percentage of (hardware) RAM size or percentage of current RAM utilisation?

Score:1
vn flag

You're confusing terms that are well defined. Let's break it down:

As a default, percentages for these individual categories are displayed.  Where two labels 
are shown below, those for more recent kernel versions are shown first.
       us, user    : time running un-niced user processes
       sy, system  : time running kernel processes
       ni, nice    : time running niced user processes
       id, idle    : time spent in the kernel idle handler
       wa, IO-wait : time waiting for I/O completion

Yes this is of total CPU availabe - also see below.

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.

Let's see what CPU time means:

CPU time (or process time) is the amount of time for which a central processing unit (CPU) was used for processing instructions ... Often, it is useful to measure CPU time as a percentage of the CPU's capacity, which is called the CPU usage. CPU time and CPU usage have two main uses.

I do agree that the wording is a bit odd, but I must assume that "total CPU time" is everything, including idle time. So I can only understand this as each task's CPU time as a percentage of the total elapsed CPU time - meaning the task's share of CPU resources out of total CPU available.

2. %MEM  --  Memory Usage (RES)
       A task's currently used share of available physical memory.

There is only one way to understand this. "Share of available physical memory" is of course just that - so percentage of total available RAM.

Overall, it wouldn't make any sense to output neither CPU nor RAM as percentage of current usage, because this metric would change all the time. So percentage of current usage wouldn't have any practical value.

anir avatar
fj flag
So, %CPU row (3rd row) is % out of **total** CPU processing power. %CPU column is sum of % of current utilization (**not total** ) of all cores? Hence, %CPU column is percentage of %CPU row value? I have exact two machines one which I ran same app and logged processing time, %CPU row and %CPU column of app. Here are observations: [link](https://i.postimg.cc/T2W1BBLk/image.png). In M1, %CPU row < %CPU col while in M2 its reverse. I am trying to make sense of this. Also, accordingly processing time also changes.
Artur Meinild avatar
vn flag
Sorry, I don't have the time. If you have issues with the `top` display, please address the developers. Thanks.
Artur Meinild avatar
vn flag
You can get CPU stats directly from `/proc/stat`, maybe use this to do your testing..
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.