I have always done as instructed by 
http://dtrace.org/guide/chp-variables.html#chp-variables
“Always assign zero to thread-local variables that are no longer in use.”

Someone recently suggested I could improve the efficiency of a script by 
setting them to -1 instead of 0, to avoid the work of deallocating and then 
reallocating.
I guess it depends on the the meaning of "no longer in use”.

syscall::mmap:entry
/monprocs[execname]/
{
   self->ts = timestamp;
   self->vts = vtimestamp;
}

syscall::mmap:return
/self->ts/
{
   this->dt = timestamp - self->ts;
   /* @time = quantize(timestamp - self->ts); */
   @cnt[zonename] = count();
   @min[zonename] = min(this->dt);
   @max[zonename] = max(this->dt);
   @avg[zonename] = avg(this->dt);
   @avgV[zonename] = avg(vtimestamp - self->vts);
   self->ts = 0;
   self->vts = 0;
}

Outside of any thread calling mmap(), self->ts and self->vts are not “in use”.
But, in this application, threads call mmap() all the time. So they will get 
allocated again very soon.

If I set them to -1 instead of 0 (and changed the predicate to check for 0 or 
-1), I can avoid a lot of work managing/cleaning up that space.

If my dtrace (or some other?) happened to use the same variable name to trace 
something else, that would be bad.

Any other reason not to do this?

Any comment on whether this is worth doing?

Kelly



-------------------------------------------
dtrace-discuss
Archives: https://www.listbox.com/member/archive/184261/=now
RSS Feed: https://www.listbox.com/member/archive/rss/184261/25769126-e243886f
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=25769126&id_secret=25769126-8d47a7b2
Powered by Listbox: http://www.listbox.com

Reply via email to