I'm seeing unexpected results using dtrace, in that my -entry
and -return
results don't always seem to correlate, I seem to see either too many or too few, and have simplified my script to explore what is going wrong.
I'm attempting to profile the amount of time spent in require "./foo"
s in my Ruby code using the following D script:
ruby*:::require-entry
{
self->start = timestamp;
@counts["require-entry"] = count();
}
ruby*:::require-return
/self->start/
{
@counts["correlated require returns"] = count();
self->start = 0;
}
ruby*:::require-return
/!self->start/
{
/* @reqTimes[copyinstr(arg0)] = quantize(self->start - timestamp); */
@counts["uncorrelated require returns"] = count();
}
Running this prints:
$ time sudo dtrace -q -s script.d -c './script.rb'
correlated require returns 5691
uncorrelated require returns 7872
require-entry 7877
sudo dtrace -q -s script.d -c './script.rb' 0.22s user 0.22s system 3% cpu 13.488 total
- am I using the
self->
variables correctly (vs.this->
or similar?) - are my predicates correct?
- when running dtrace this way, do I "race" against the probes activating before the script starts?