Cover V07, I05
Article
Figure 1
Figure 2
Sidebar 1

may98.tar


Sidebar : Looking at a CPU Hog

To demonstrate how the CPU% metrics appear in real life, I started a CPU-consuming program and monitored the ps command and the top program output. I performed this test on two systems: "somer" is a SparcServer 1000 with two CPUs running Solaris 2.5; "barnstable" is an AIX G30 with two CPUs running AIX 4.1.4.

The program takes over one of the CPUs on each system. All measurements were done by hand; timings were begun from the moment the program started executing. In all cases, I monitored the CPU% utilization of the process as reported by the respective tool.

Figure 1 shows the output from "somer". Note that it took over 60 seconds before the CPU% utilization showed 50% (one out of two CPUs being dedicated to this process). If we happened to have been looking at this process's CPU% utilization early in the life of the process (say between seconds 10 and 20), we might have erroneously concluded that the process was consuming about 20% of the CPU.

Figure 2 presents the output from "barnstable". Here we see different behavior for our CPU% utilization metrics. The ps command says from the very beginning that 50% of the CPU is being consumed. But, this too is potentially misleading because the output from ps shows us the percent utilization since the process started running. Since the process was nothing other than a CPU hog, the 50% shown is valid. Imagine, however, a situation where the process has already been running for a total of 10 minutes (but not doing anything to consume the CPU) and only now in the last minute has it started being CPU intensive. For some period of time, we will see the CPU% utilization sitting at approximately 5% (1 minute divided by 10 minutes divided by 2 CPUs). After 5 minutes, we see 25%.

Also note in Figure 2 that the top variable CPU% is simply wrong. This appears to be a top problem wherein the metric is not adjusted for the number of CPUs. The second metric, WCPU%, is properly adjusted. Other than that, top's output is consistent with what we saw in Figure 1.