PerfettoTrigger: use SDK directly if available
PerfettoTrigger is a utility class that currently fork-execs a system
binary to send a named trigger to the system tracing daemon. It's used
from a variety of processes through classes like InteractionJankMonitor
and LatencyTracker. Calling processes include system_server, systemui,
launcher, settings, etc.
Nowadays, system_server and systemui register with a perfetto SDK
library (through os.PerfettoTrace), which enables sending the triggers
without fork-exec.
This patch adds a way to dynamically figure out whether the calling
process is "using" the SDK, and if so redirecting PerfettoTrigger to the
latter's method.
Note that robustly figuring out that the SDK is usable would require a
lot of plumbing since the registration with the tracing daemon is
asynchronous (though there is an expectation that it will succeed
eventually for platform processes). So we instead do a simpler check
that the calling process initiated the registration. This should be
sufficient for practical uses of PerfettoTrigger.
Beyond lower overhead when triggering, this also fixes a long-standing
limitation where PerfettoTrigger calls from within system_server would
actually fail on selinux denials on fork-execing the trigger binary.
I've kept the rate-limiting done by PerfettoTrigger even if using the
SDK to preserve current triggering rates. We'd need to evaluate
unlimiting the triggers separately.
Flag: android.os.perfetto_sdk_tracing_v2
Test: manually with the local device_config overrides documented in
InteractionJankMonitor's javadoc. Confirmed that systemui was
using the SDK while nexuslauncher was fork-execing.
Fixes: 186213514
Change-Id: Ia911dccf619922b430de5026cac14cc34bf6f96d
Loading
Please register or sign in to comment