About Talks Articles

Mac OS X: Tracking Disk I/O Activities

2 min read

Many modern laptops come with an SSD (solid-state drive) instead of a traditional magnetic disk. Because it is silent, it is not possible to hear the spinning sound anymore as the disk enters a period of high activities. This can be bad, often a continuous I/O access indicates a problem in the running system.

For latest Mac OS X versions, fortunately we have iotop and fs_usage (need sudo to run). The former will sample I/O events by process, sampled in a periodic interval (default to 5 seconds). The latter does the work different as it simply fills the screen with all disk-related system calls and related activities. I found out that iotop works really good as a general monitoring, just to ensure that nothing really saturates the disk bandwidth, while fs_usage is fantastic to find out who is actually doing something crazy there.

Generally, I prefer to do some filtering, e.g.:

sudo fs_usage -f filesys

only bugs you with file system events, everything else is ignored. There are other filter modes such as network, exec, path, etc. Refer to the manpage for more detailed info.

Running fs_usage once a while reveals how web browsers are still very chatty with respect to disk I/O. For example, running Chrome and opening about:blank still shows countless calls like the following. Of course without knowing what files are associated with that handle 20 and 21, it’s impossible to reach any conclusion.

22:16:39.355599  write   F=21   B=0x1         0.000004   Google Chrome.4147134
22:16:39.355611  write   F=21   B=0x1         0.000002   Google Chrome.4147134
22:16:39.355779  read    F=20   B=0x1         0.000003   Google Chrome.4147134
22:16:39.355788  read    F=20   B=0x1         0.000002   Google Chrome.4147134

At least when I close Chrome, all those calls disappear. The same goes with many applications, until I hit Parallels Desktop. There are some running services which keep accessing the virtual machine files every second, long after any virtual machine have been shutdown. This is quite mysterious to me. I solve the issue by stopping the launch daemon:

sudo launchctl stop com.parallels.desktop.launchdaemon

Obviously, before launching Parallels again, I’ll start the daemon manually (do the same like above but replace stop with start).

If you never use iotop or fs_usage before, give them a try. Do you find any I/O activities from some application you would never thought before?

Related posts:

♡ this article? Explore more articles and follow me Twitter.

Share this on Twitter Facebook Google+

comments powered by Disqus