是如何在linux负荷计算权重选择?权重、负荷、如何在、linux

2023-09-11 22:49:48 作者:-激情澎湃゛小斌哥、

在Linux中,平均负载被说成是在1分钟/ 5分钟/ 15分钟。内核使用的公式实际上是一个指数移动平均线。

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.

如果我们定义 cpuload(1)作为CPU负载1分钟的第一个计算和激活()作为函数返回过程中的状态的数字运行,或在系统上可运行,然后用内核的公式来计算的第n 的CPU负载1分钟是:

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) 0;这是第一次执行之前存储在存储器中的值 cpuload()

cpuload(0) is 0; it is the value stored in memory before the first execution of cpuload().

我的问题是,如何在权重2 -5.log2(E)/ 60 选择?在我看来,2 -5/60 会更好,因为1分钟本来进程数的半衰期(因为(2 -5/60 ) 12 = 1)。

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

也许,如果我上传 cpuload的明确公式是有帮助的(N)除上述(单击右键看到它在全尺寸)的递归定义:

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

推荐答案

考虑一个特定的负载样品的激活(K)的,有多少是样本有助于 cpuload(K + D) 的,用于增加的ð的值。有几个关键的看法:

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:

的激活(K)的是由一些重量的 W(D)multipled 的决定其贡献的 cpuload(K + D)的 的 W(D)的是总是小于1。 的 W(D)的指数随的ð的增加​​。 在计算机算法具有有限precision。 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.

总之,这些点意味着有一些的 DMIN 的,使得对于 D> DMIN ,活性(K)W(D)= 0 等的激活(K)的对的 cpuload(K + D)没有影响的。总之, cpuload(N)的仅受的 DMIN 的previous样的影响。

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.

另一种方式来看待这个是 cpuload(N)的备忘数据由​​

Another way to look at this is that cpuload(n) forgets data after a time defined by

衰减指数,它定义的 DMIN 和 采样频率。

这最后的跨pretation给出了1分钟,5分钟和15分钟的平均负载的意义。衰减和取样间隔被选择成使得后分别1,5,和15分钟的这些平均负载忘记过去。

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.

 
精彩推荐
图片推荐