Andrew Mercer
on this page

Tools for measuring where a Linux system spends its time. Start broad (load, CPU, memory, disk, network) and narrow to a process or device. Network-side tools live in Linux networking.

Reading load and the CPU picture first

Most performance investigations start at the CPU, but a busy-looking CPU is frequently a symptom: the processor may just be waiting on disk or network. Before touching any CPU-specific tool, get the rough shape from top and uptime:

  • Run queue: every runnable process waits in the run queue for a CPU. Load average counts runnable tasks (plus, on Linux, tasks in uninterruptible I/O wait), so a high load with an idle CPU points at storage, not compute.
  • Context switches happen whenever the kernel swaps one process off a CPU for another, and each one costs cache warmth. Interrupts from hardware also cause switches. A rough rule of thumb is that context switches running around ten times the interrupt rate are unremarkable. Far higher ratios suggest too many processes competing for CPU. Compare cs and in in vmstat.
  • iowait (wa) is CPU time spent idle while I/O is outstanding. Sustained high values mean look at storage and network, not the processor.

Method

  1. Load and headline numbers: uptime, top, vmstat.
  2. Which resource: CPU (sysstat mpstat, turbostat), memory (vmstat, slabtop, numastat), disk (iostat, iotop), network (nethogs and friends).
  3. Which process: top, atop, pmap, strace, perf.
  4. History: sysstat/sar, pcp, atop logs.
  5. Benchmark or reproduce: fio, ioping.

Further reading

in this section
* atop — advanced system and process monitor with history/
* blktrace — block layer i/o tracing/
* dstat — combined resource statistics (and dool)/
* fio — flexible i/o tester/
* ioping — disk i/o latency/
* iostat — cpu and disk i/o statistics/
* iotop — per-process disk i/o/
* numastat — numa memory statistics/
* pcp — performance co-pilot/
* perf — linux profiling and tracing/
* pmap — process memory map/
* rdmsr / wrmsr — read cpu model-specific registers/
* slabtop — kernel slab cache usage/
* strace — trace system calls/
* sysstat — sar, iostat, mpstat, pidstat and historical metrics/
* the flush (writeback) kernel thread/
* tiptop — per-process hardware counters/
* top — interactive process viewer/
* turbostat — cpu frequency, c-states, and power/
* uptime and load averages/
* vmstat — virtual memory, cpu, and block i/o statistics/