linux – %CPU列和顶部加载

linux – %CPU列和顶部加载,第1张

概述我的一个应用程序显示顶部的CPU%非常高,但负载非常低. myapp总是需要大约30%,显示在“top”命令的最顶层,但是负载总是像0.00,所以我很困惑load和%CPU列之间有什么区别? top - 14:09:54 up 62 days, 2:52, 1 user, load average: 0.00, 0.00, 0.00Tasks: 124 total, 1 running 我的一个应用程序显示顶部的cpu%非常高,但负载非常低.
myapp总是需要大约30%,显示在“top”命令的最顶层,但是负载总是像0.00,所以我很困惑load和%cpu列之间有什么区别?

top - 14:09:54 up 62 days,2:52,1 user,load average: 0.00,0.00,0.00Tasks: 124 total,1 running,123 sleePing,0 stopped,0 zombIEcpu0  :  0.0%us,0.0%sy,0.0%ni,99.7%ID,0.3%wa,0.0%hi,0.0%si,0.0%stcpu1  :  0.0%us,99.3%ID,0.3%si,0.0%stMem:   2054824k total,1440364k used,614460k free,4644k buffersSwap:  4194296k total,16604k used,4177692k free,610784k cachedPID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND                                                                                         14774 root      20   0 1201m 9416 1856 S 28.3  0.5 376:13.50 myapp                                                                                        14746 MysqL     20   0 2012m 157m 3888 S  0.3  7.8   5:01.08 MysqLd

谁能告诉我理解%cpu和负载之间的差异?

先感谢您!

解决方法 例如top中显示的%cpu是进气的,即当时正在使用的cpu,而正常运行时间显示的负载是平均值:

It conventionally appears in the form of three numbers which represent
the system load during the last one-,five-,and fifteen-minute
periods.

从Wikipedia.

随着时间的推移,这些应该会收敛,但是虽然%cpu是100%最大值,但是当有进程等待时,负载可以高于1.例如:

For example,one can interpret a load average of “1.73 0.50 7.98” on a
single-cpu system as:

during the last minute,the cpu was overloaded by 73% (1 cpu with 1.73 runnable processes,so that 0.73 processes had to wait for a turn)

during the last 5 minutes,the cpu was underloaded 50% (no processes had to wait for a turn)

during the last 15 minutes,the cpu was overloaded 698% (1 cpu with 7.98 runnable processes,so that 6.98 processes had to wait for a
turn)

更新:

我现在才注意到你的进程使用了​​28%的cpu,而top报告说两个cpu的空闲率都是> 99%.我无法在我的linux系统(Ubuntu 12.04,Intel i7-3770K quadcore HT)上重现这一点,请参阅下面的屏幕截图.

正常设置,无负载,显示所有核心的平均cpu使用率:

top - 18:10:04 up  7:50,2 users,0.05,0.15Tasks: 157 total,156 sleePing,0 zombIEcpu(s):  0.0%us,99.9%ID,0.0%wa,0.0%stMem:  16528224k total,1124956k used,15403268k free,148772k buffersSwap: 15624188k total,0k used,15624188k free,670460k cached  PID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND    7022 root      20   0     0    0    0 S    0  0.0   0:00.14 kworker/0:1            1 root      20   0  3640 2060 1324 S    0  0.0   0:01.23 init                   2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd               3 root      20   0     0    0    0 S    0  0.0   0:00.14 ksoftirqd/0            6 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0

在一个核心上满载(运行yes> / dev / null),显示所有核心的平均cpu使用率:

top - 18:11:58 up  7:52,load average: 0.11,0.07,2 running,155 sleePing,0 zombIEcpu(s): 12.5%us,87.5%ID,1124880k used,15403344k free,148824k buffersSwap: 15624188k total,670472k cached  PID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND            8254 tim       20   0  4188  280  228 R  100  0.0   0:04.88 yes                    1 root      20   0  3640 2060 1324 S    0  0.0   0:01.23 init                   2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd               3 root      20   0     0    0    0 S    0  0.0   0:00.15 ksoftirqd/0            6 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0

与2)相同,但显示每核cpu使用率:

top - 18:13:47 up  7:54,load average: 0.86,0.36,0.24Tasks: 157 total,100.0%ID,0.0%stcpu2  :  0.3%us,0.0%stcpu3  :  0.0%us,0.0%stcpu4  :  0.0%us,0.0%stcpu5  :100.0%us,0.0%ID,0.0%stcpu6  :  0.0%us,0.0%stcpu7  :  0.0%us,1124756k used,15403468k free,148840k buffersSwap: 15624188k total,670472k cached  PID USER      PR  NI  VIRT  RES  SHR S %cpu %MEM    TIME+  COMMAND            8254 tim       20   0  4188  280  228 R  100  0.0   1:53.98 yes                    1 root      20   0  3640 2060 1324 S    0  0.0   0:01.23 init                   2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd               3 root      20   0     0    0    0 S    0  0.0   0:00.15 ksoftirqd/0            6 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0

N.B.:我确实注意到,第一个统计数据顶部显示没有显示是的100%cpu使用情况,类似于你所拥有的.也许那就是问题?

总结

以上是内存溢出为你收集整理的linux – %CPU列和顶部加载全部内容,希望文章能够帮你解决linux – %CPU列和顶部加载所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1025960.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存