Tuesday, July 17, 2007

fs_usage and power consumption

One of the concerns when using a notebook is to minimize computer activity when running off the battery. In particular, regular disk accesses will tend to use battery juice. On Linux, Intel has developed an utility called PowerTOP to identify such culprits but it is not yet available on MacOS X.

Using fs_usage in the shell (with option -e to include the PID for Terminal and Console), I've immediately found out two things:

1) a rogue Skype process active even if the application did not appear as active in the dock

while running normally, Skype will constantly stat these files:

Library/Application Support/Skype/shared.xml
Library/Application Support/Skype/rngadam/config.xml

1) that MicrosoftMouseHelper was constantly hitting on a file, even if the mouse is actually disconnected:

/Users/rngadam/Library/Preferences/ByHost/com.apple.HIToolbox.001b6391a6f6.plist

This is at a rate of twice a second with operations open/fstat/read/close! This directory seems to contain various files with the plist extension including things referencing iTunes, print cache and system preferences. However, iTunes while running does not generate that kind of poor behavior. I went ahead and remove MicrosoftMouse.kext and the Microsoft Mouse preference pane from System...

Spelling as you type seems to be a also badly behaved. For example, having it active while typing in this sticky will generate a bunch of lseek/read every time the spacebar is pressed (but no files are specified, so perhaps this is only to a memory mapped file?).

While typing this, some kind of cleanup task also started:

find / ( ! -fstype local -o -fstype fdesc -o -fstype devfs ) -a -prune -o -print

hitting on every file on the disk. This cleaning up continues with makewhatis and other related stuff even if the computer power is disconnected while it is accessing the disk. These and similar housekeeping scripts are in /etc/periodic

Closer to home, GoogleDesktopDaemon wakes regularly, even if Enable Google Desktop Indexing is actually disabled in the Preferences. Even after reboot, GoogleDesktopDaemon is still waking up! This is where it comes from:

/Library/Google/Google Desktop/GoogleDesktopDaemon.bundle/Contents/MacOS/GoogleDesktopDaemon

Definitely something to investigate in-depth.

In conclusion, fs_usage is very useful to discover

  • daemons that are waking up when they are not supposed to
  • possibly useless processes that are waking up too often
  • identify file accesses
  • processes that are still running when they shouldn't
  • applications preferences that are putting an unnecessary strain on the system

Possible areas of investigation:

  • Why is the GoogleDesktopDaemon there even if disabled?
  • is 'file notify' implemented in the kernel? and if so, why is it not used consistently?
  • Could a housekeeping shell scripts register to receive notification and suspend its work when computer switches to battery power? Especially if current battery status is at a low-level? Perhaps a wrapper around the shell script that would potentially suspend its task?
  • Can the Intel utility to measure power consumption be ported to MacOS X?
  • Collect statistics on total power usage for processes?

No comments: