[dtrace-discuss] Getting around tail-calls...

Rich Brown
2005-07-28T22:53:43Z

Hi All,

I''m looking for some advice:

I want to use Dtrace to observe the latency and results of all vnode
operations. This is something we want to do in production.

For example, I''d like to run a Dscript using the fop_read:entry/return
FBT probes to save uio_resid on entry, subtract off uio_resid after the
vop call returns then display the number bytes transferred.  Throw in a
little vtimestamp subtraction and I''ve got latency also.

The trouble is that most of the fop calls are tail-call optimized which
(as you well know) makes the return probe fire before the
(*(vp)->v_op->vop_read)(vp, uiop, ioflag, cr, ct); happens.  I''ve
tried
the following:

- I followed the suggestions in the Dtrace cookbook for dealing with
 tail-call optimized routines:   http://dtrace.eng/recipes/chasetail.html .
 After the 100K+ probes are enabled, there is a significant performance hit
 on the system. (And I''ll want to use this on systems that are already
 having problems.)

- I looked at our production compilers and noticed that they have lower
 levels of optimization (e.g., -xO1) that won''t do tail-call
optimization,
 but seems so wrong way on several levels:  It''s (a) compiler-specific
and
 (b) too  big of a hammer (even just for vnode.c).

- I added a static probe after the vop call.  This works and has good
 observed performance, but all I''m really doing is subverting the
tail-call
 optimization. Seems like there must be a better way.

Any suggestions?  Thanks for your help,

  Rich