JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Dynamic Tracing Guide     Oracle Solaris 11 Information Library
search filter icon
search icon

Document Information


1.  About DTrace

2.  D Programming Language

3.  Aggregations

4.  Actions and Subroutines

5.  Buffers and Buffering

6.  Output Formatting

7.  Speculative Tracing

8.  dtrace(1M) Utility

9.  Scripting

10.  Options and Tunables

11.  Providers

12.  User Process Tracing

13.  Statically Defined Tracing for User Applications

14.  Security

15.  Anonymous Tracing

16.  Postmortem Tracing

17.  Performance Considerations

Limit Enabled Probes

Use Aggregations

Use Cacheable Predicates

18.  Stability

19.  Translators

20.  Versioning

Use Cacheable Predicates

DTrace predicates are used to filter unwanted data from the experiment by tracing data is only traced if a specified condition is found to be true. When enabling many probes, you generally use predicates of a form that identifies a specific thread or threads of interest, such as /self->traceme/ or /pid == 12345/. Although many of these predicates evaluate to a false value for most threads in most probes, the evaluation itself can become costly when done for many thousands of probes. To reduce this cost, DTrace caches the evaluation of a predicate if it includes only thread-local variables (for example, /self->traceme/) or immutable variables (for example, /pid == 12345/). The cost of evaluating a cached predicate is much smaller than the cost of evaluating a non-cached predicate, especially if the predicate involves thread-local variables, string comparisons, or other relatively costly operations. While predicate caching is transparent to the user, it does imply some guidelines for constructing optimal predicates, as shown in the following table:

mumblecurthread, mumblepid, tid
curpsinfo->pr_fname, curthread->t_procp->p_user.u_comm
curpsinfo->pr_pid, curthread->t_procp->p_pipd->pid_id
curlwpsinfo->pr_lwpid, curthread->t_tid
curthread-> any member, curlwpsinfo-> any member, curpsinfo-> any member

The following example is not recommended:

        follow[pid, tid] = 1;

/follow[pid, tid]/

/follow[pid, tid]/
        follow[pid, tid] = 0;

The following example using thread-local variables is preferable:

        self->follow = 1;


        self->follow = 0;

A predicate must consist exclusively of cacheable expressions in order to be cacheable. The following predicates are all cacheable:

/execname == "myprogram"/
/execname == $$1/
/pid == 12345/
/pid == $1/
/self->traceme == 1/

The following examples, which use global variables, are not cacheable:

/execname == one_to_watch/
/pid == pid_i_care_about/
/self->traceme == my_global/