Linux 负载计算中的权重是如何选择的?

发布于 2024-10-21 17:54:49 字数 625 浏览 1 评论 0原文

在 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:

enter image description here

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):

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倒数 2024-10-28 17:54:49

考虑一个特定的负载样本active(K),以及该样本对cpuload(K+d)的贡献程度,以增加d的值。有一些关键的观察结果:

  • active(K) 乘以某个权重 W(d) 以确定其对 cpuload(K+d) 的贡献嗯>。
  • W(d) 始终小于一。
  • W(d) 随着 d 的增加呈指数下降。
  • 计算机算术的精度是有限的。

总之,这些点意味着存在一些 dmin,使得对于 d>dminactive(K)W(d)=0 并且所以active(K)cpuload(K+d)没有影响。简而言之,cpuload(n) 仅受 dmin 先前样本的影响。

另一种看待这个问题的方法是,cpuload(n)

  • 衰减指数(定义了 dmin)和
  • 采样频率定义的时间后忘记了数据。

此最终解释给出了 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:

  • active(K) is multipled by some weight W(d) to determine its contribution to cpuload(K+d).
  • W(d) is always less than one.
  • W(d) decreases exponentially as d increases.
  • computer arithmetic has finite precision.

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

  • the decay exponent, which defines dmin, and
  • the sampling frequency.

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.

好听的两个字的网名 2024-10-28 17:54:49

我猜他们希望正在运行的进程的平均生命周期为一分钟。

I'm guessing they wanted the mean lifetime of the contribution of a running process to be one minute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文