CPU Utilization
How is it calculated?
CPU utilization is measured by the time a CPU instance is busy performing work during an interval, expressed as a percentage. It can be measured as the time a CPU is not running the kernel idle thread but is instead running user-level application threads or other kernel threads, or processing interrupts.
β Brendan Gregg
Problematic is that the waiting time for other resources is part of the utilization.
90 % CPU utilization:
Stalled means the processor was not making forward progress with instructions, and usually happens because it is waiting on memory I/O. The ratio I drew above (between busy and stalled) is what I typically see in production. Chances are, you're mostly stalled, but don't know it.
β Brendan Gregg
Is CPU Utilization a Bad Metric?
Thoughts by Adrian Cockcroft
The most fundamental assumption here is that the average service time is constant, and does not depend upon the load level. This is one of the assumptions that has been broken by virtualization, Hyper-threading and variable speed power-saving CPUs.
β Adrian Cockcroft (http://www.hpts.ws/papers/2007/Cockcroft_CMG06-utilization.pdf)
Challenges:
- Hypervisors not fully mapping CPU to a guest which results in incomplete data
- Hyper-Threading which creates βslowβ cores and βfastβ cores with the former being strongly non-linear in performance
- CPU frequency changes over time
- CPU utilization doesn't mean "busy"! It means "non-idle time" and includes the waiting time ("stalled") e.g. due to memory I/O
Thoughts by Brendan Gregg
CPU Utilization is Wrong
CPU utilization is wrong - YouTube
- High CPU utilization can mean that the CPU is waiting for some other resource
- You need to understand on what frequency the CPU is running (tool: showboost)
- Instructions per Cycle (IPC) can be very helpful to find low-level performance issues
CPU Utilization vs. CPU Time
Energy Consumption of Software β Using CPU Time or CPU Utilization as a Proxy
Tools
Windows
- Task Manager
Linux
- top
- htop
- ctop