在Linux上执行此命令时:
# cat /proc/loadavg
0.75 0.35 0.25 1/25 1747
前三个数字是负载平均值。最后两个数字是什么?
最后一个数字每秒钟增加2,我应该担心吗?
在Linux上执行此命令时:
# cat /proc/loadavg
0.75 0.35 0.25 1/25 1747
前三个数字是负载平均值。最后两个数字是什么?
最后一个数字每秒钟增加2,我应该担心吗?
该文件的前三个字段是负载平均数,它们表示等待运行的作业数量(状态为R)或等待磁盘I/O的作业数量(状态为D),分别计算过去 1、5 和 15 分钟的平均值。这些数字与 uptime(1) 和其他程序给出的负载平均数相同。
第四个字段由两个数字组成,用斜杠(/)分隔。第一个数字是当前正在执行的内核调度实体(进程、线程)的数量;此数字将小于或等于 CPU 数量。斜杠后面的值是当前存在于系统上的内核调度实体的数量。
第五个字段是最近在系统上创建的进程的 PID。
make
的同时应考虑这些值,使用参数 --load-average=N.N
。如果 make
导致负载平均数比 CPU 核心数高,则应使用减少的 --load-average
重新启动 make
。这样,编译过程不会导致系统过载。 - user6901258我想评论被接受的答案。
第四个字段由两个用斜杠(/)分隔的数字组成。其中第一个是当前正在执行的内核调度实体(进程、线程)的数量;这将小于或等于CPU的数量。
我编写了一个测试程序,从输入中读取整数N,然后创建N个线程并永久运行它们。在RHEL 6.5计算机上,我有8个处理器,每个处理器都有超线程。无论如何,如果我运行我的测试并创建128个线程,我会看到第四个字段的值大于128,例如135。这篇文章支持了我的观察结果:http://juliano.info/en/Blog:Memory_Leak/Understanding_the_Linux_load_average
值得注意的是,proc(5) 手册页中目前的说明(截至 2009 年3月 man-pages 版本 3.21)是错误的。它报告第四个字段的第一个数字为当前正在执行的调度实体的数量,因此预测它不能大于 CPU 的数量。这与真实实现不符,其中该值报告当前可运行线程的数量。https://docs.fedoraproject.org/en-US/Fedora/17/html/System_Administrators_Guide/s2-proc-loadavg.html
proc
手册页面的 /proc/loadavg
部分来获取相关信息:$ man proc | sed -n '/loadavg/,/^$/ p'
/proc/loadavg
The first three fields in this file are load average figures giving the number of jobs in the run queue
(state R) or waiting for disk I/O (state D) averaged over 1, 5, and 15 minutes. They are the same as
the load average numbers given by uptime(1) and other programs. The fourth field consists of two num‐
bers separated by a slash (/). The first of these is the number of currently runnable kernel schedul‐
ing entities (processes, threads). The value after the slash is the number of kernel scheduling enti‐
ties that currently exist on the system. The fifth field is the PID of the process that was most
recently created on the system.
为此,您需要在CentOS7/RedHat7上安装man-pages
软件包或在Ubuntu 20.04/22.04 LTS上安装manpages
软件包。
watch -n0.1 cat /proc/loadavg
命令,你会看到最后一个值以这个速率递增,因为每次执行cat
命令都会创建一个新的进程。所以仅仅查看这个文件就会改变结果(让我想起了某些事情)。 - billpcs