Content deleted Content added
→CPU load vs CPU utilization: Encyclopedic tone & accurate; prosody and nuance. |
m →Reckoning CPU load: Hz is correct upper case, while lower as hertz. |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 6:
== Unix-style load calculation ==
All Unix and Unix-like systems generate a dimensionless [[Software metric|metric]] of three "load average" numbers in the [[kernel (operating system)|kernel]]. Users can easily query the current result from a [[Unix shell]] by running the <code>[[uptime]]</code> command:
<syntaxhighlight lang="console">
$ uptime
14:34:03 up 10:43, 4 users, load average: 0.06, 0.11, 0.09
</syntaxhighlight>
The [[W (Unix)|<code>w</code>]] and [[
In operating systems based on the [[
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
Line 29 ⟶ 30:
}}</ref>
An idle computer has a load number of 0 (the idle process is not counted). Each [[process (computing)|process]] using or waiting for [[Central processing unit|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) [[Process state|states]]. However, Linux also includes processes in uninterruptible sleep states (usually waiting for [[Hard disk drive|disk]] activity), which can lead to markedly different results if many processes remain blocked in [[Input/output|I/O]] due to a busy or stalled I/O system.<ref>{{Cite web|url=
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.
Line 54 ⟶ 55:
== 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 HZ frequency setting and tested on each clock tick. This setting defines the kernel clock tick rate in [[
<syntaxhighlight lang="c">
Line 93 ⟶ 94:
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>
A post on the Linux mailing list considers its {{tt|+1}} tick insufficient to avoid
== Other system performance commands ==
Other commands for assessing system performance include:
* <code>[[uptime]]</code>{{Snd}} the system reliability and load average
* <code>[[
* <code>[[
* <code>[[
* <code>dool</code> (formerly <code>dstat</code>),<ref>{{cite web |url=https://github.com/scottchiefbaker/dool |title=dool - Python3 compatible clone of dstat |last=Baker |first=Scott |date=September 28, 2022 |website=[[GitHub]] |access-date=November 22, 2022 |quote=...Dag Wieers ceased development of Dstat...}}</ref> <code>atop</code>{{Snd}} helps correlate all existing resource data for processes, memory, paging, block I/O, traps, and CPU activity.
* <code>[[
* <code>nethogs</code>{{Snd}} interactive network traffic viewer per process
* <code>iotop</code>{{Snd}} interactive I/O viewer<ref>{{Cite web|url=
* <code>[[
* <code>[[
* <code>[[mpstat]]</code>{{Snd}} for CPU statistics
* <code>tload</code>{{Snd}} load average graph for terminal
Line 115 ⟶ 117:
* [[CPU usage]]
== References ==
{{reflist}}
== External links ==
* {{cite web
|author = Brendan Gregg
|title = Linux Load Averages: Solving the Mystery
|url =
|date = 8 August 2017
|access-date = 2018-01-22
Line 135 ⟶ 137:
* {{cite web
|title = Understanding Linux CPU Load{{Snd}} when should you be worried?
|url =
|author = Andre Lewis
|date = 31 July 2009
Line 143 ⟶ 145:
|author = Ray Walker
|title = Examining Load Average
|url =
|publisher = Linux Journal
|date = 1 December 2006
|