Alan Hargreaves' Blog

The ramblings of a former Australian SaND TSC* Principal Field Technologist

DTrace Lab in the performance track at CEC

We have just been helping out in the DTrace lab for the performance track at CEC. On having a look at exercise 1, we suggested to the attendees that they attempt the other exercises and come back to this one. The exercise was:

Enhance /usr/demo/dtrace/iosnoop to be able to detect reads that are satisfied by the filesystem cache (UFS: pagecache).

We then went off to write our own versions of an answer to the problem.I started from scratch, and (referring back to a previous blog where I did some digging into this code), came up with the following:

#!/usr/sbin/dtrace -s
#pragma D option quiet
BEGIN { printf("Collecting ...\n"); }
syscall::read*:entry {
self->interest = 1;
self->file = fds[arg0].fi_name;
self->phys = 0;
/* we only increment this kstat if we have to go to disk, from a filesystem */
sysinfo:::bread /self->interest/ { self->phys = 1;}
syscall::read*:return /self->interest/ {
this->str = self->phys
? "Physical reads"
: "Cache Reads";
@[this->str, self->file] = count();
self->interest = 0;
END { printa("%@6d %s %s\n", @); }

On running this you get output like:

209 Cache Reads jaxrpc-impl.jar
211 Cache Reads appserv-admin.jar
311 Cache Reads xalan.jar
354 Cache Reads ttysrch
372 Cache Reads jaxr-impl.jar
373 Cache Reads auxv
500 Cache Reads appserv-assemblytool.jar
1216 Cache Reads 
1324 Cache Reads appserv-rt.jar
1392 Cache Reads clone@0:ptm
83181 Cache Reads psinfo

Of course by the time I finished writing this, pretty much everything in the only ufs filesystem on the box had been cached 🙂


Written by Alan

November 13, 2008 at 7:01 pm

Posted in Solaris

%d bloggers like this: