Footprints
Some time ago I looked into using DTrace to investigate application footprint and minimisation. If we can easily capture everything that an application touches in filesystem namespace then this is a real no brainer. I looked at this, produced something and kind of drifted onto other things without really finishing it (as I generally do).
Yesterday a colleague of mine hassled me to produce some D that would produce a minimised version of our native profiling tool, collect, which is part of the Performance Analyzer available in the Sun One Studio 8 Compiler Collection. Having a minimised version of such as tool is really useful for "carrying" around with you in case you feel the need to profile. Having gone back to the minimisation stuff I wrote about a year ago I thought I'd start again with a different and simpler approach (I think someone stole my password and re-wrote my original effort 'cause it was that bad ...).
Here's how I did it and it's simple. Firstly, here's the D (io.d):
Also, to make sure that I see all the physical I/O generated I don't want the page cache getting in the way caching pages for me! To flush the page cache of all pages for a particular filesystem we can just do `lockfs -f /filesystem`. Nice little trick when you need to make sure you actually do the I/O ...
So, in one window I do:
With the above script I managed to capture the basic footprint of the profiler which I can then tar up and take around with me. This example would have been perfect if we had something akin to strncmp() so that I could predicate on files in /opt/SUNWspro as well as they are the only files I'm really intersted in. However, the chaps are on to that so it's probably working its way through one of their keyboards as I type. Trace on.
Yesterday a colleague of mine hassled me to produce some D that would produce a minimised version of our native profiling tool, collect, which is part of the Performance Analyzer available in the Sun One Studio 8 Compiler Collection. Having a minimised version of such as tool is really useful for "carrying" around with you in case you feel the need to profile. Having gone back to the minimisation stuff I wrote about a year ago I thought I'd start again with a different and simpler approach (I think someone stole my password and re-wrote my original effort 'cause it was that bad ...).
Here's how I did it and it's simple. Firstly, here's the D (io.d):
#pragma D option quiet
io:::start
/ curpsinfo->pr_taskid == $1 /
{
@[args[2]->fi_pathname] = sum(args[0]->b_bcount);
}
END
{
printa("%s\n", @);
}
I want to see all filesystem reads and writes that the collect binary and all its children do. In order for me to isolate the work I use the task primitive in Solaris. Tasks are really cool and very much underused. Basically, your login shell gets assigned a taskid and then all it's children inherit this taskid so we can group them by this same taskid. If I want to get a new taskid to start a sub-grouping of work I can use the newtask command to obtain a new taskid. Simple.Also, to make sure that I see all the physical I/O generated I don't want the page cache getting in the way caching pages for me! To flush the page cache of all pages for a particular filesystem we can just do `lockfs -f /filesystem`. Nice little trick when you need to make sure you actually do the I/O ...
So, in one window I do:
#newtask -v 8 #lockfs -f /And then in another window I run my script:
dtrace -o /tmp/collect.out -s ./io.d 8I then run my collect command in my taskid==8 shell. In my script above I simply predicate on the current threads taskid so I only look at I/O that comes from the collect process and it's children that I've just started! Marvellous.
With the above script I managed to capture the basic footprint of the profiler which I can then tar up and take around with me. This example would have been perfect if we had something akin to strncmp() so that I could predicate on files in /opt/SUNWspro as well as they are the only files I'm really intersted in. However, the chaps are on to that so it's probably working its way through one of their keyboards as I type. Trace on.