DTrace is very good

One of the things which would make Macrobug’s life much easier is if Symbian OS had DTrace or an equivalent. DTrace is a dynamic tracing framework which allows arbitrary APIs and function calls to be instrumented at run-time without any changes to any code. That way, the Macrobug tools would be able to hook in and monitor what’s happening inside the device without any changes to the kernel or application binaries.

Such days are probably some way away, but I can look forward to it!

Meanwhile, just as an example of how great DTrace is on a real system, I’ve just used it to diagnose a problem with my Mac. Macs include a backup mechanism known as Time Machine. This does incremental backups, in my case onto a RAIDed NAS server sitting elsewhere in my house (which in turn has parts of it rsync’ed to an off-site backup regularly).

Time Machine backs up automatically every hour in the background, and keeps as many incremental backups as it can fit onto the backup disk. There’s therefore an incentive for the backups to be smallish, as then your history will go back further. I found that most Macs seem to back up about 1-3 MB every hour, whereas mine always backed up 105-110MB. What was this mysterious file which was changing every hour that seemed to be 105MB big?

To diagnose this, I used Apple’s whizzy DTrace front-end, known as Instruments, to attach to the “backupd” process which does the time machine backups. I used some preset DTrace probes which can instrument the APIs used to read and write files, thus giving me lists of all the reads and writes, including their sizes, filenames, and even call stacks. And there’s even a nice UI to look at the results:

Instruments UI

The mysterious 105MB file turned out to be the article database for my RSS reader. It appears that they store all the articles in one file (messages.db) instead of many small ones. So, each time it refreshes (more than once per hour) the file changes, and Time Machine chooses to back it up.

So, the solution is simple – check whether there’s a fixed version of Vienna, or move to a new RSS reader, or tell Time Machine to ignore this file.

As for Symbian, perhaps there will be something like DTrace one day! I can’t wait!

One Response to “DTrace is very good”

  1. David Crookes Says:

    another possible solution: a script that creates rsync style differences of that file over time, plus time machine ignores the orig but backs up the smaller diffs, for which you have a recombine script if need be. Time machine ought adopt this for suitable files.

Leave a Reply