Linux 负载计算中的权重是如何选择的?
在 Linux 中,平均负载为 1 分钟/5 分钟/15 分钟。内核使用的公式实际上是指数移动平均线。
如果我们将cpuload(1)
定义为CPU负载1min的第一次计算,并将active()
定义为返回处于“running”或“状态”的进程数量的函数runnable”,那么内核用来计算第 n 个 1 分钟 cpu 负载的公式为:
cpuload(0)
为 0;它是第一次执行 cpuload() 之前存储在内存中的值。
我的问题是,权重 2-5.log2(e)/60 是如何选择的?在我看来,2-5/60 会更好,因为 1 分钟将是进程数量的半衰期(因为 (2-5/60) 12 = 1/2)。
除了上面的递归定义之外,如果我发布 cpuload(n) 的显式公式(右键单击以查看完整尺寸),也许会有所帮助:
In Linux, the load average is said to be on 1min/5min/15min. The formula used by the kernel is actually an Exponential moving average.
If we define cpuload(1)
as the first computation of the cpu load 1min, and active()
as the function returning the number of process in state "running" or "runnable" on the system, then the formula used by the kernel to compute the nth cpu load 1min is:
cpuload(0)
is 0; it is the value stored in memory before the first execution of cpuload()
.
My question is, how was the weighting 2-5.log2(e)/60 chosen? In my opinion, 2-5/60 would have been better because 1min would have been the half-life of the number of process (because (2-5/60)12 = 1/2).
Maybe it's helpful if i post the explicit formula of cpuload(n)
in addition to the recursive definition above (right-click to see it in full size):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑一个特定的负载样本active(K),以及该样本对cpuload(K+d)的贡献程度,以增加d的值。有一些关键的观察结果:
总之,这些点意味着存在一些 dmin,使得对于 d>dmin,active(K)W(d)=0 并且所以active(K)对cpuload(K+d)没有影响。简而言之,cpuload(n) 仅受 dmin 先前样本的影响。
另一种看待这个问题的方法是,cpuload(n) 在
此最终解释给出了 1 分钟、5 分钟和 15 分钟负载平均值的含义。选择衰减和采样间隔,以便这些负载平均值分别在 1、5 和 15 分钟后忘记过去的情况。
Consider a particular load sample active(K), and how much that sample contributes to cpuload(K+d), for increasing values of d. There are a few key observations:
Together, these points mean that there is some dmin such that, for d>dmin, active(K)W(d)=0 and so active(K) has no influence on cpuload(K+d). In short, cpuload(n) is only influenced by dmin previous samples.
Another way to look at this is that cpuload(n) forgets data after a time defined by
This final interpretation gives the meaning of the 1-minute, 5-minute, and 15-minute load averages. The decay and the sampling interval are chosen so that these load averages forget the past after 1, 5, and 15 minutes respectively.
我猜他们希望正在运行的进程的平均生命周期为一分钟。
I'm guessing they wanted the mean lifetime of the contribution of a running process to be one minute.