How were the weightings in the linux load computation chosen?

柔情痞子 提交于 2019-12-31 11:08:09

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5892104/how-were-the-weightings-in-the-linux-load-computation-chosen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!