From: Nick Alcock <nick.alcock@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH v2] Optimize USDT discovery a little
Date: Tue, 22 Jul 2025 11:45:50 +0100 [thread overview]
Message-ID: <871pq87bc1.fsf@esperi.org.uk> (raw)
In-Reply-To: <20250625060305.15707-1-eugene.loh@oracle.com> (eugene loh's message of "Wed, 25 Jun 2025 02:03:01 -0400")
On 25 Jun 2025, eugene loh outgrape:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> 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.
I'm pretty amazed you can even detect this optimization, but the code
change feels like a good idea anyway, if just on code reuse grounds.
> 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".
It's a shame this is necessary though. (In practice, nobody is ever
going to do it for BEGIN, at least -- but it's common enough with other
probes to be worth taking advantage of.)
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
modulo the tiny nit below.
> - char lastchar = pdp->prv[len - 1];
> + char lastchar = (pdp->prv[0] != '\0' ? pdp->prv[len - 1] : '*');
I'd be a bit more belt-and-braces here, given that if this goes wrong
it's a buffer overrun:
> + char lastchar = ((pdp->prv[0] != '\0' && len > 0) ? pdp->prv[len - 1] : '*');
> @@ -555,6 +559,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;
This could do with a blank line above the first if in this hunk, I think?
>
> /*
> * If we cannot ignore this statement, try to use uprp.
> @@ -751,13 +757,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);
(straight moves into the callee, ok.)
--
NULL && (void)
prev parent reply other threads:[~2025-07-22 10:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 6:03 [PATCH v2] Optimize USDT discovery a little eugene.loh
2025-06-25 6:03 ` [PATCH v2 3/4] Sync up the version numbers eugene.loh
2025-07-22 10:51 ` [DTrace-devel] " Nick Alcock
2025-06-25 6:03 ` [PATCH v2 4/4] test: Add test for predefined preprocessor definitions eugene.loh
2025-06-25 6:03 ` [PATCH v2 2/2] Extend the USDT bit mask to multiple words eugene.loh
2025-07-22 12:34 ` Nick Alcock
2025-07-23 0:47 ` Eugene Loh
2025-06-25 6:03 ` [PATCH] test: Extend timeout for many-pids test eugene.loh
2025-07-22 12:44 ` Nick Alcock
2025-07-22 10:45 ` Nick Alcock [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871pq87bc1.fsf@esperi.org.uk \
--to=nick.alcock@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=eugene.loh@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox