Optimize USDT discovery a little
PATCH 1/1 Optimize USDT discovery a little
From: Eugene Loh <[email protected]>
We want to reduce the performance cost of USDT discovery if possible.
Specifically, a number of statements -- with probe descriptions such as "dtrace:::BEGIN" that could never specify USDT probes -- will not get their clause flags set with DT_CLSFLAG_USDT_EXCLUDE. So these statements get considered unnecessarily during periodic probe discovery.
Therefore:
*) Expand ignore_clause(dtp, n, uprp) to support the case uprp==NULL.
This case is independent of any knowledge of a specific underlying probe.
*) During probe discovery, check ignore_clause(dtp, i, NULL). This
sets the DT_CLSFLAG_USDT_[INCLUDE|EXCLUDE] flag and allows faster exclusion of statements that do not need to be reconsidered.
To take advantage of this optimization, users should specify providers. E.g., instead of "BEGIN" (which could conceivably be a USDT probe), specify "dtrace:::BEGIN".
--- libdtrace/dt_prov_uprobe.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
libdtrace/dt_prov_uprobe.c +10 -8
@@ -267,7 +267,8 @@ clean_usdt_probes(dtrace_hdl_t *dtp)/* * Judge whether clause "n" could ever be called as a USDT probe -* for this underlying probe. +* for this underlying probe. We can pass uprp==NULL to see if +* the clause can be excluded for every probe. */ static int ignore_clause (dtrace_hdl_t *dtp,int n,const dt_probe_t *uprp)
@@ -275,13 +276,16 @@ ignore_clause(dtrace_hdl_t *dtp, int n, const dt_probe_t *uprp)dtrace_stmtdesc_t *stp = dtp->dt_stmts[n];dtrace_probedesc_t *pdp = &stp->dtsd_ecbdesc->dted_probe; +if (stp ==NULL ) +return 1 ; +/* * Some clauses could never be called for a USDT probe, * regardless of the underlying probe uprp. Cache this * status in the clause flags for dt_stmts[n]. */ if (dt_stmt_clsflag_test (stp,DT_CLSFLAG_USDT_INCLUDE |DT_CLSFLAG_USDT_EXCLUDE ) ==0 ) { -char lastchar = pdp->prv[strlen (pdp->prv) -1 ]; +char lastchar = (pdp->prv[0 ] !='\0' ? pdp->prv[strlen (pdp->prv) -1 ] :'*' );/* * If the last char in the provider description is
@@ -314,6 +318,8 @@ ignore_clause(dtrace_hdl_t *dtp, int n, const dt_probe_t *uprp) }if (dt_stmt_clsflag_test (stp,DT_CLSFLAG_USDT_EXCLUDE ) ==1 )return 1 ; +if (uprp ==NULL ) +return 0 ;/* * If we cannot ignore this statement, try to use uprp.
@@ -504,13 +510,9 @@ static int discover(dtrace_hdl_t *dtp)*/ memset (&pcb,0 ,sizeof (dt_pcb_t));for (i =0 ; i < dtp->dt_stmt_nextid; i++) { -dtrace_stmtdesc_t *stp; - - stp = dtp->dt_stmts[i]; -if (stp ==NULL ) +if (ignore_clause (dtp, i,NULL ))continue ; -if (dt_stmt_clsflag_test (stp,DT_CLSFLAG_USDT_EXCLUDE ) !=1 ) -dt_pid_create_usdt_probes (&stp->dtsd_ecbdesc->dted_probe, dtp, &pcb); +dt_pid_create_usdt_probes (&dtp->dt_stmts[i]->dtsd_ecbdesc->dted_probe, dtp, &pcb); }return 0 ;
Signature · 1 line
2.43.5