Re: What is CPU Utilization, anyway?

I don't think I've ever seen a scientific definition, but I understand CPU Utilisation to mean:


- for a single process: U = ( cpu_time / real_time ) * 100
- for the whole cpu: U = ( 1 - ( cpu_time_used_by_the_idle_thread / real_time )) * 100

where:
- cpu_time is the sum of time spent in user mode and time spent in kernel (sys) mode to service the process
- real_time is the time as measured by any time piece.

The *NIX time command gives these metrics after completing a command. E.g.:

   $ time play ~/sound/beamusup.wav

   ...
   Done.

   real    0m4.445s
   user    0m0.128s
   sys    0m0.008s

The CPU utilisation of this command would in my understanding have been: ( ( 0.128 + 0.008 ) / 4.445 ) * 100 = 3.06 %

Extrapolating that, the percentage shown by top, prstat, taskmanager, etc. would be the cpu time consumed by a process during the sample time, typically 1-3 sec. So 60% over 5 minutes, provided that the process indeed is running all that time, would mean that that process has indeed hugged the cpu for 3 minutes. Perhaps continuously, perhaps not, the metric does not show that.

I'm pretty sure that the process occupies the entire cpu when it executes. The longer it executes, and the higher its cpu utilisation, the longer other processes must wait, which means that the computer becomes increasingly unresponsive as cpu utilisation by a *single* process increases. When the CPU utilisation hits 100%, the OS may no longer be able to regain the CPU and a reboot is the only way to regain control (on a 1-cpu system of course).

This is not to be confused with 100% CPU utilisation as measured in the 2nd way (0% idle thread time), which merely means that the cpu is in constant use. Other than for your electricity bill this is not necessarily bad, as long as many processes occupy the cpu for short periods of time.

Hth
Tony

Oracle Dba Wannabe wrote:
Keeping things simple, on a one 1 CPU box I pop up task manager or run 'top' and see CPU Utilization at 60% what does this really mean? We cannot consume 60% of a CPU, right? your process is either on CPU which means it consumes the entire CPU or it does not, a procoess cannot consume half of a CPU or 60% for that matter. With that said, does the 60% then show me the CPU time my process has consumed? So if over a 5 minute interval I see that the CPU utilized was 60%, I would say the process during the 5 minute interval consumed 60/100*(5) = 3 minutes of CPU Time. This may not be 3 minutes of continuous time - assuming waits for i/o in between, but generally speaking its 3 minutes of CPU time, correct? If this is true, with 'top' running or task manager on windows running - when I see these figures in real time what are they in reference to? I mean what is the time interval that CPU utilization is being based on? is it that particular second in time? - if that makes sense? For example 60% of that 1 second when I look at the tool that is reporting these values to me? Would it depend on when the process was created, when it lasted used CPU?
Thanks anyone.


--
http://www.freelists.org/webpage/oracle-l


Other related posts: