Load (computing): Difference between revisions

Content deleted Content added
m Bot: http → https
m Reckoning CPU load: Hz is correct upper case, while lower as hertz.
 
(3 intermediate revisions by the same user 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 [[Toptop (Unixsoftware)|<code>top</code>]] commands show the same three load average numbers, as do a range of [[graphical user interface]] utilities.
 
In operating systems based on the [[Linux (kernel)|Linux kernel]], this information can be easily accessed by reading the [[procfs|<code>/proc/loadavg</code>]] file.
 
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 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 [[Hertzhertz]] (times per second), and it defaults to 100 for 10ms10&nbsp;ms ticks. Kernel activities use this number of ticks to time themselves. Specifically, the timer.c::calc_load() function, which calculates the load average, runs every {{tt|1=LOAD_FREQ = (5*HZ+1)}} ticks, or about every five seconds:
 
<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 Moire[[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}} [httphttps://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>[[uptime]]</code>{{Snd}} the system reliability and load average
* <code>[[Toptop (Unixsoftware)|top]]</code>{{Snd}} for an overall system view
* <code>[[Vmstat (Unix)|vmstat]]</code>{{Snd}} vmstat reports information about runnable or blocked processes, memory, paging, block I/O, traps, and CPU.
* <code>[[Htop (Unix)|htop]]</code>{{Snd}} interactive process viewer
* <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>[[Iftop|iftop]]</code>{{Snd}} interactive network traffic viewer per interface
* <code>nethogs</code>{{Snd}} interactive network traffic viewer per process
* <code>iotop</code>{{Snd}} interactive I/O viewer<ref>{{Cite web|url=https://man7.org/linux/man-pages/man8/iotop.8.html|title = Iotop(8) - Linux manual page}}</ref>
* <code>[[Iostat (Unix)|iostat]]</code>{{Snd}} for storage I/O statistics
* <code>[[Netstat (Unix)|netstat]]</code>{{Snd}} for network statistics
* <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