Operating System - HP-UX
1829608 Members
1395 Online
109992 Solutions
New Discussion

how to understand the cpu usage on top output?

 
Xiaogang Zheng
Advisor

how to understand the cpu usage on top output?

Hi,

My question is based on my following top output copy:

Copy Start ----------------------------------------------------------------------------------------------

System: coach Fri Aug 17 15:50:34 2007
Load averages: 0.43, 0.30, 0.20
708 processes: 688 sleeping, 19 running, 1 zombie
Cpu states:
CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS
0 1.11 2.6% 0.0% 2.0% 95.4% 0.0% 0.0% 0.0% 0.0%
1 0.14 3.0% 0.0% 2.8% 94.2% 0.0% 0.0% 0.0% 0.0%
2 0.09 2.6% 0.0% 3.0% 94.4% 0.0% 0.0% 0.0% 0.0%
3 0.39 1.6% 0.0% 4.2% 94.2% 0.0% 0.0% 0.0% 0.0%
--- ---- ----- ----- ----- ----- ----- ----- ----- -----
avg 0.43 2.4% 0.0% 3.0% 94.6% 0.0% 0.0% 0.0% 0.0%

Memory: 10403856K (6031896K) real, 11771056K (6775636K) virtual, 2501644K free Page# 1/28

CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
2 ? 29860 oracle 168 20 25240K 3872K sleep 162:20 1.62 1.62 dbsnmp
2 ? 13573 oracle 154 20 24588K 6688K sleep 1627:28 1.29 1.28 tnslsnr
1 ? 16174 oracle 154 20 504M 3484K sleep 0:00 1.31 1.11 oracledev02
0 ? 7147 oracle 154 20 300M 3176K sleep 3:04 1.03 1.03 oracledev3
0 ? 22728 oracle 154 20 623M 6612K sleep 5:20 1.03 1.02 oracleifsipts2
1 ? 5521 oracle 154 20 411M 6868K sleep 3:23 0.85 0.85 oracleifsipsbx
3 ? 22684 oracle 154 20 628M 6612K sleep 4:14 0.85 0.85 oracleifsiptst
1 ? 14732 oracle 154 20 587M 3804K sleep 5:09 0.77 0.76 oracleifsvtst1
2 ? 14111 oracle 154 20 416M 12628K sleep 0:09 0.72 0.72 oracleifsipsbx
2 ? 22748 oracle 154 20 624M 6868K sleep 3:34 0.68 0.68 oracleifsipts2
1 ? 5533 oracle 154 20 411M 6868K sleep 2:34 0.67 0.67 oracleifsipsbx
1 ? 37 root 152 20 12832K 12832K run 168:45 0.65 0.64 vxfsd
3 ? 22674 oracle 154 20 629M 6868K sleep 3:49 0.64 0.64 oracleifsiptst
0 ? 27274 oracle 154 20 390M 3548K sleep 5:26 0.59 0.59 oracledev04
1 pts/te 15642 oracle 178 20 7140K 1496K run 0:01 0.59 0.59 top
0 ? 27288 oracle 154 20 390M 3804K sleep 5:31 0.59 0.58 oracledev04
2 ? 27126 oracle 152 20 158M 133M run 17:34 0.57 0.57 oidldapd
2 ? 15445 oracle 154 20 412M 7748K sleep 2:59 0.49 0.49 oracleifsvtst2

...
Copy End --------------------------------------------------------------------------------------------

How to match the information on “Cpu states” on top several lines with the information on %CPU on the process list?

For example:
If I sum the %CPU for all processes that is running on cpu (2), I should get 100% (or less ?)
1.62 dbsnmp
1.28 tnslsnr
0.72 oracleifsipsbx
0.68 oracleifsipts2
0.57 oidldapd
0.49 oracleifsvtst2
……

If I sum the (USER, NICE, SYS, IDLE) on cpu (2), I get 100%.
2.6% 0.0% 3.0% 94.4%

My question is that inside all processes that are running on cup 2, there are user processes and system processes, so, which one of the 100%cpu time belong to, the 5.6% (USER 2.6% + SYS 3.0%) of cpu RUNNING time, or just belong to 2.6% of USER, or it includes the IDLE time?

Thanks,
Xiaogang
8 REPLIES 8
Xiaogang Zheng
Advisor

Re: how to understand the cpu usage on top output?

Hi,

Due to the copy/paste problem, the && under the line of "0.49 oracleifsvtst2" should be ...., indicating hundres of other processes.

Thanks,
Xiaogang
Dennis Handly
Acclaimed Contributor

Re: how to understand the cpu usage on top output?

(You're putting too much thought into this. ;-)

>or it includes the IDLE time?

I would think it includes all but idle time.
I may be wrong about SYS but when you use time(1), it does have a SYS contribution.
Xiaogang Zheng
Advisor

Re: how to understand the cpu usage on top output?

Hi Dennis,

From the top man, it says %CPU stands for "Raw CPU percentage", The raw means exactly time usage within the given (default 5 seconds) refresh time frame, is that true?

So, based on the above example data, the process 'dbsnmp' had consumed the cpu 2 (5 seconds * 1.62%) = 0.081 seconds in the last 5 seconds.

Or, another explanation, the process â dbsnmpâ had consumed the cpu 2 (5 seconds * 2.6% (USES) * 1.62%) = 0.002106 seconds in the last 5 seconds.

I ask this question because we had the situation like following. We are in the testing phase, we are considering if it goes to production, how performance it will be.


Cpu states:
CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS
0 0.46 29.1% 0.0% 6.9% 64.0% 0.0% 0.0% 0.0% 0.0%
â ¦

CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
0 ? 6969 oracle 168 20 650M 198M sleep 53:16 61.09 61.98 oracledev03
â ¦


The process â oracledev03â has consumed 61.98% cpu time or (29.1% * 61.98% = ) 17.75% cpu time?

Thanks,
Xiaogang
Dennis Handly
Acclaimed Contributor

Re: how to understand the cpu usage on top output?

>it says %CPU stands for "Raw CPU percentage", The raw means exactly time usage within the given (default 5 seconds) refresh time frame, is that true?

It seems like it.

>based on the above example data, the process dbsnmp had consumed the CPU 2 (5 seconds * 1.62%) = 0.081 seconds

Well, CPU 2 and any other CPU that its threads could have run on.

>the process dbsnmp had consumed the CPU 2 (5 seconds * 2.6% (USER) * 1.62%) = 0.002106

No, that's not it.

>CPU LOAD USER NICE SYS IDLE
0 0.46 29.1% 0.0% 6.9% 64.0%

>CPU PID UNAME TIME %WCPU %CPU COMMAND
0 6969 oracle 53:16 61.09 61.98 oracledev03

>The process oracledev03 has consumed 61.98% cpu time or (29.1% * 61.98% = ) 17.75% CPU time?

It's 61.98%.
Xiaogang Zheng
Advisor

Re: how to understand the cpu usage on top output?

Hi Dennis,

But your first answer "I would think it includes all but idle time.". So, the %CPU should be â raw CPU percentage of all running processes in the period when the cpu is not idleâ .

The 61.98% is within full 5 seconds including running and idle, or during only cpu is running within 5 seconds.?

Thanks,
Xiaogang
Dennis Handly
Acclaimed Contributor

Re: how to understand the cpu usage on top output?

>But your first answer "I would think it includes all but idle time.". So, the %CPU should be raw CPU percentage of all running processes in the period when the CPU is not idle.

I was trying to point out that it included USER and NICE but I wasn't sure about SYS. So basically for a process, you don't need to look at the CPU summary at the top.

>The 61.98% is within full 5 seconds including running and idle, or during only cpu is running within 5 seconds?

The full 5 seconds. The other part could be used by other processes or waiting/idle.

Note if more than 100%, you are using threads and more than one CPU.
Xiaogang Zheng
Advisor

Re: how to understand the cpu usage on top output?

Thank you.
Dennis Handly
Acclaimed Contributor

Re: how to understand the cpu usage on top output?

You haven't assigned any points yet. You can reopen this thread and assign points by:
http://forums1.itrc.hp.com/service/forums/helptips.do?#41
http://forums1.itrc.hp.com/service/forums/helptips.do?#33