Content deleted Content added
m →Reckoning CPU load: Hz is correct upper case, while lower as hertz. |
|||
(43 intermediate revisions by 29 users not shown) | |||
Line 1:
{{Short description|Amount of computational work that a computer system performs}}
{{
{{more citations needed|date=November 2010}}
[[File:Big-load.png|thumb|[[htop]] displaying a significant computing load (top right: ''Load average:'')
== Unix-style load calculation ==
All Unix and Unix-like systems generate a dimensionless [[Software metric|metric]] of three "load average" numbers in the [[kernel (
<
$ uptime
14:34:03 up 10:43, 4 users, load average: 0.06, 0.11, 0.09
</syntaxhighlight>
The [[W (Unix)|<
In operating systems based on the [[Linux kernel]], To explore this kind of information in depth, according to the Linux's [[Filesystem Hierarchy Standard]], architecture-dependent information are exposed on the file <code>/proc/stat</code>.<ref>{{Cite web
|url = https://www.kernel.org/doc/html/latest/admin-guide/cpu-load.html
|title = CPU load
|access-date=2023-10-04
}}</ref><ref>{{Cite web
|url = https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html
|title = /proc
|access-date=2023-10-04
|website = Linux Filesystem Hierarchy
}}</ref><ref>{{Cite web
|url = https://www.kernel.org/doc/html/latest/filesystems/proc.html#miscellaneous-kernel-statistics-in-proc-stat
|title = Miscellaneous kernel statistics in /proc/stat
|access-date=2023-10-04
}}</ref>▼
An idle computer has a load number of 0 (the idle process
Systems calculate the load ''average'' as the [[Moving average#Exponential moving average|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.<ref name="drdobbs">{{cite web |url=
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.
=== Interpretation ===
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
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 [[Thread (
== CPU load
The comparative study of different load indices carried out by Ferrari et al.<ref name="Empirical load">Ferrari, Domenico; and Zhou, Songnian; "[http://www.eecs.berkeley.edu/Pubs/TechRpts/1987/CSD-87-353.pdf An Empirical Investigation of Load Indices For Load Balancing Applications]", Proceedings of Performance
== Reckoning CPU load ==
On Linux systems, the load-average is not calculated on each clock tick, but driven by a variable value that is based on the
<
unsigned long avenrun[3];
Line 54 ⟶ 74:
}
}
</syntaxhighlight>
▲</ref>
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 :▼
▲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
<source lang="c">▼
#define FSHIFT 11 /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
#define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */
#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
#define EXP_5 2014 /* 1/exp(5sec/5min) */
Line 78 ⟶ 90:
load += n*(FIXED_1-exp); \
load >>= FSHIFT;
</syntaxhighlight>
The "sampled" calculation of load averages is a somewhat common behavior; FreeBSD, too, only refreshes the value every five seconds. The interval is usually taken to not be exact so that they do not collect processes that are scheduled to fire at a certain moment.<ref>{{cite web |title=How is load average calculated on FreeBSD? |url=https://unix.stackexchange.com/a/342778 |website=Unix & Linux Stack Exchange}}</ref>
==Other system performance commands==▼
A post on the Linux mailing list considers its {{tt|+1}} tick insufficient to avoid [[Moiré pattern|Moiré artifacts]] from such collection, and suggests an interval of 4.61 seconds instead.<ref>{{cite web |last1=Ripke |first1=Klaus |title=Linux-Kernel Archive: LOAD_FREQ (4*HZ+61) avoids loadavg Moire |url=https://lkml.iu.edu/hypermail/linux/kernel/1111.1/02446.html |website=lkml.iu.edu |date=2011}} [https://ripke.com/loadavg/moire graph & patch<!-- Actual title at target: Moiré patterns in linux load average (Moiré mangled in title as Moiré) -->]</ref> This change is common among [[Android (operating system)|Android system]] kernels, although the exact expression used assumes an HZ of 100.<ref>{{cite web |title=Patch kernel with the 4.61s load thing · Issue #2109 · AOSC-Dev/aosc-os-abbs |url=https://github.com/AOSC-Dev/aosc-os-abbs/issues/2109 |website=GitHub |language=en}}</ref>
▲== Other system performance commands ==
Other commands for assessing system performance include:
* <
* <code>[[
* <code>[[
*
* <
* <code>[[iftop
* <
* <
*
*
* <
* <
* <
* <
== See also ==
* [[CPU usage]]
==
{{reflist}}▼
== External links ==
* {{cite web
|author = Brendan Gregg
|title = Linux Load Averages: Solving the Mystery
|url =
|date = 8 August 2017
|
}}
* {{cite web
|title = UNIX Load Average
|url = http://www.teamquest.com/pdfs/whitepaper/ldavg1.pdf
|author = [[Neil J. Gunther]]
|publisher = TeamQuest
|
* {{cite web
|title = Understanding Linux CPU Load
|url =
|author = Andre Lewis
|date = 31 July 2009
|
}} Explanation using an illustrated traffic analogy.
* {{cite web
|author = Ray Walker
|title = Examining Load Average
|url =
|publisher = Linux Journal
|date = 1 December 2006
|
}}
* {{cite web
Line 139 ⟶ 156:
|publisher = LoadAvg
}}
▲{{reflist}}
[[Category:Operating system technology]]
|