词条 | Load (computing) |
释义 |
Unix-style load calculationAll Unix and Unix-like systems generate a dimensionless metric of three "load average" numbers in the kernel. Users can easily query the current result from a Unix shell by running the uptime command: The w and top commands show the same three load average numbers, as do a range of graphical user interface utilities. In Linux, they can also be accessed by reading the An idle computer has a load number of 0 (the idle process isn't counted). Each process using or waiting for CPU (the ready queue or run queue) increments the load number by 1. Each process that terminates decrements it by 1. Most UNIX systems count only processes in the running (on CPU) or runnable (waiting for CPU) states. However, Linux also includes processes in uninterruptible sleep states (usually waiting for disk activity), which can lead to markedly different results if many processes remain blocked in I/O due to a busy or stalled I/O system.[1] This, for example, includes processes blocking due to an NFS server failure or too slow media (e.g., USB 1.x storage devices). Such circumstances can result in an elevated load average which does not reflect an actual increase in CPU use (but still gives an idea of how long users have to wait). Systems calculate the load average as the exponentially damped/weighted moving average of the load number. The three values of load average refer to the past one, five, and fifteen minutes of system operation.[2] Mathematically speaking, all three values always average all the system load since the system started up. They all decay exponentially, but they decay at different speeds: they decay exponentially by e after 1, 5, and 15 minutes respectively. Hence, the 1-minute load average consists of 63% (more precisely: 1 - 1/e) of the load from the last minute and 37% (1/e) of the average load since start up, excluding the last minute. For the 5- and 15-minute load averages, the same 63%/37% ratio is computed over 5 minutes and 15 minutes respectively. Therefore, it is not technically accurate that the 1-minute load average only includes the last 60 seconds of activity, as it includes 37% of the activity from the past, but it is correct to state that it includes mostly the last minute. For single-CPU systems that are CPU bound, one can think of load average as a measure of system utilization during the respective time period. For systems with multiple CPUs, one must divide the load by the number of processors in order to get a comparable measure. For example, one can interpret a load average of "1.73 0.60 7.98" on a single-CPU system as:
This means that this system (CPU, disk, memory, etc.) could have handled all of the work scheduled for the last minute if it were 1.73 times as fast. In a system with four CPUs, a load average of 3.73 would indicate that there were, on average, 3.73 processes ready to run, and each one could be scheduled into a CPU. On modern UNIX systems, the treatment of threading with respect to load averages varies. Some systems treat threads as processes for the purposes of load average calculation: each thread waiting to run will add 1 to the load. However, other systems, especially systems implementing so-called M:N threading, use different strategies such as counting the process exactly once for the purpose of load (regardless of the number of threads), or counting only threads currently exposed by the user-thread scheduler to the kernel, which may depend on the level of concurrency set on the process. Linux appears to count each thread separately as adding 1 to the load.[3] CPU load vs CPU utilizationThe comparative study of different load indices carried out by Ferrari et al.[4] reported that CPU load information based upon the CPU queue length does much better in load balancing compared to CPU utilization. The reason CPU queue length did better is probably because when a host is heavily loaded, its CPU utilization is likely to be close to 100% and it is unable to reflect the exact load level of the utilization. In contrast, CPU queue lengths can directly reflect the amount of load on a CPU. As an example, two systems, one with 3 and the other with 6 processes in the queue, are both very likely to have utilizations close to 100% although they obviously differ.{{or|date=May 2013}} Reckoning CPU loadOn Linux systems, the load-average is not calculated on each clock tick, but driven by a variable value that is based on the Hz frequency setting and tested on each clock tick. (Hz variable is the pulse rate of particular Linux kernel activity. 1 Hz is equal to one clock tick; 10ms by default.) Although the Hz value can be configured in some versions of the kernel, it is normally set to 100. The calculation code uses the Hz value to determine the CPU Load calculation frequency. Specifically, the timer.c::calc_load() function will run the algorithm every 5 * Hz, or roughly five times per second. Following is that function in its entirety: The countdown is over a {{code|LOAD_FREQ}} of 5 Hz.[5] The avenrun array contains 1-minute, 5-minute and 15-minute average. The {{code|CALC_LOAD}} macro and its associated values are defined in sched.h : Other system performance commandsOther commands for assessing system performance include:
See also
External links
|author = Brendan Gregg |title = Linux Load Averages: Solving the Mystery |url = http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html |date = 8 August 2017 |accessdate = 2018-01-22 }}
|title = UNIX Load Average – Part 1: How It Works |url = http://www.teamquest.com/pdfs/whitepaper/ldavg1.pdf |author = Neil J. Gunther |publisher = TeamQuest |format = pdf |date = |accessdate = 2009-08-12
|title = Understanding Linux CPU Load - when should you be worried? |url = http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages |author = Andre Lewis |date = 31 July 2009 |accessdate = 2011-07-21 }} Explanation using an illustrated traffic analogy.
|author = Ray Walker |title = Examining Load Average |url = http://www.linuxjournal.com/article/9001 |publisher = Linux Journal |date = 1 December 2006 |accessdate = 2011-07-21 }}
|author = Karsten Becker |title = Linux OSS load monitoring toolset |url = http://www.loadavg.com |publisher = LoadAvg }} Notes1. ^http://linuxtechsupport.blogspot.com/2008/10/what-exactly-is-load-average.html 2. ^{{cite web |url=http://www.linuxjournal.com/article/9001 |title=Examining Load Average |first=Ray |last=Walker |date=1 December 2006 |work=Linux Journal |accessdate=13 March 2012 }} 3. ^See http://serverfault.com/a/524818/27813 4. ^Ferrari, Domenico; and Zhou, Songnian; "An Empirical Investigation of Load Indices For Load Balancing Applications", Proceedings of Performance ’87, the 12th International Symposium on Computer Performance Modeling, Measurement, and Evaluation, North Holland Publishers, Amsterdam, The Netherlands, 1988, pp. 515-528 5. ^ 6. ^This paper's discussion is useful, but it contains at least one error, in equation 3 (Section 4.2, page 12): The equation should be instead of References 2 : Operating system technology|Articles with example C code |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。