Identifying constant disk writes on Mac OS X

A couple of month ago, I noticed that I was having a constant stream of disk write of about 1MB/s on my MacBook (as seen in Activity That would eventually drain my battery faster when running unplugged.

First thing to do was to identify the culprit, the process, that generate those writes.

As I'm not familiar with the BSD sub-system internals, I Googled and found a list of DTrace one-liners that proved to be handy:


The first one:

# dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'

It shows you the names of the process doing I/O operations.

From the result I immediatly spotted a process from Postgresql that was generating a fair amount of I/O while no queries/vacuum where running.

Now, I know the source might be in Postgresql, but what was happenning? what files were concerned by theses I/O?

I needed to know what files where opened, so this DTrace gave me the next answer :

# dtrace -n 'syscall::open*:entry { printf("%s %s", execname, copyinstr(arg0) ); }'

This one prints the name of the files being opened by the running processes :

  0  18514              open_nocancel:entry postgres global/pg_database
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  1  17728                          open:entry mdworker /.vol/234881026/52307726//Contents/PkgInfo
  1  17728                          open:entry mdworker /opt/local/var/db/postgresql84/defaultdb/pg_stat_tmp/pgstat.stat
  1  17728                          open:entry mds .
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat

From this output, I found that it would be related to the pg_stat mecanism.

I edited the `postgresql.conf' file and disabled the stat collection by setting:

track_activities = off
track_counts = off

Then, after restarting postgresql, the continuous flow of writes was gone.

Thank you DTrace!

Ce contenu a été publié dans regular. Vous pouvez le mettre en favoris avec ce permalien.