Observation and diagnostics · Intermediate

Reading per-process resource use with pidstat

Align process identity and sampling windows, then use CPU, fault and I/O observations to choose the next execution path to investigate.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Narrow the view to individual processes
  2. Fix the PID and observation window
  3. Relate CPU, faults and I/O
  4. Account for exited work and attribution limits
  5. Ask Logeia about this articleCheck your understanding

Narrow the view to individual processes

Pidstat is a Linux sysstat tool for observing resource use by processes and, where requested, their threads. It can narrow a host-wide incident to work whose CPU, memory, I/O or context-switch behavior changed during the same interval. A PID is not a permanent identity: operating systems reuse process numbers. Correlate it with start time, command and the relevant service or container before comparing distant observations as though they describe the same execution. This is especially important in systems that frequently launch short-lived worker processes.

Fix the PID and observation window

For example, pidstat -u -r -d -w -p 1234 1 5 observes PID 1234 at one-second intervals for five reports. Replace the example PID and check permissions and /proc visibility. Add thread reporting with -t when that is the intended scope. Also establish how CPU percentages are normalized and whether a value represents one processor’s worth of execution or a share of the whole system. The command is not accompanied by invented measured output; collect observations from the actual target and align their windows before comparing resources.

sh
pidstat -u -r -d -w -p 1234 1 5

Relate CPU, faults and I/O

Minor faults and major faults represent different events, so not every fault should be counted as a storage read. Process I/O rates likewise are not a universal measurement of every byte requested through application APIs or served from cache. Distinguish voluntary context switches from involuntary ones, and avoid treating either increase as automatically pathological. A drop in CPU use alongside more waiting can motivate an investigation of synchronization or I/O. The interpretation remains a hypothesis until additional evidence connects the process’s behavior with the slow application operation.

Account for exited work and attribution limits

Short-lived children can start and exit between samples, leaving substantial work invisible in a long-interval process list. Attribution is also complicated by asynchronous I/O, kernel activity and requests delegated to shared services. Combine pidstat with application request rates and latency, plus device-level observations such as iostat. Sampling every process at an extremely fine interval has its own overhead, so narrow the scope deliberately. The objective is to identify which resource and execution path to investigate next, not to infer a complete causal story from one unusually large number next to a PID.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Understand the systems behind the web · STEP 5

Choose a learning path