The Heisenberg Uncertainty Principle

or, The Dilemma Of Monitoring CPU Usage Closely

by Bob Clark

originally published September 2004; last updated May 2007

Physicists were the first to be frustrated by the phenomenon that the more closely you observe something, the more you affect it. Whether it’s a thermometer slightly impacting the temperature of what you’re measuring, or the Heisenberg principle and the inability to measure both velocity and position of a subatomic particle, or Peek-a-Boo and closely measuring processes’ resource usage, the act of measuring isn’t just a passive act: it influences what you’re trying to measure.

This brief essay explores the dilemma, basically from the perspective of Peek-a-Boo.

Peek-a-Boo gathers many pieces of information. One of the most CPU-expensive pieces is how much CPU time a process has used. In some ways this is a Catch-22, because if you’re trying to analyse which processes are using the most CPU, oftentimes it will be the one that’s doing the checking.

Even command-line tools such as top will use a surprising amount of CPU while watching other processes’ usage of CPU time. For some reason, the operating system simply uses a large chunk of the processor to track and report this information.

Two questions will naturally arise when somebody is faced with this dilemma:

  1. At what point does tracking CPU start to appreciably affect system behavior?
  2. How can I minimize the CPU usage of Peek-a-Boo when tracking all processes’ CPU usage?

The Effect Of CPU Usage Tracking

Although any observation of CPU usage will itself cause more CPU time to be used, in most cases that effect is tiny. In fact, if the total CPU usage is less than 100%, that “elbow room” suggests that even gathering the CPU usage information isn’t using enough processor power to substantially affect the processes whose CPU usage is being monitored.

And Peek-a-Boo is the perfect “self-monitor” in this environment. Peek-a-Boo and its helper daemon are just normal processes, so by watching their CPU usage characteristics it is easy to tell whether the CPU usage spent monitoring CPU usage is worthwhile or needs adjustment.

Balancing Peek-a-Boo’s CPU Tracking

The second question is really about finding the perfect balance between lowering how much CPU time Peek-a-Boo needs and maximizing the resolution of the data for processes whose CPU usage is being tracked.

All of the CPU-intensive capabilities of Peek-a-Boo have been designed to be adjustable. If you see Peek-a-Boo using too much of the CPU, you can generally turn down the frequency which which Peek-a-Boo updates its information.

Peek-a-Boo’s Process Throb view is a perfect example of this ability to fine-tune how Peek-a-Boo works for you. There are three things that Process Throb does that use the CPU:

  1. A low-CPU-usage update of all the icons’ positions. Since this uses very little CPU, this is updated very frequently by default.
  2. A medium-CPU-usage update of what all processes are currently running. This is updated less frequently than the icon position update by default.
  3. A high-CPU-usage update of the CPU usage of all processes. This happens by default at a lower frequency.

Even though we made some guesses for these parameters, they may not work best for you. You may have a faster computer and want more frequent CPU-usage updates. Or you may want to minimize Peek-a-Boo’s CPU usage and set updates to happen very infrequently.

All options that affect Peek-a-Boo’s CPU usage are adjustable in the Preferences panes.