Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7cdc3b1 authored by Zim's avatar Zim
Browse files

Skip tracing missing binder txn names

This works around b/156126072 which introduces app startup latencies
that are multiplied with binder txn tracing enabled.

Skiping tracing interfaces without binder txn names avoids tracing
interfaces like ContentProviders and app-defined interfaces. This is
still an improvement on the status quo since we still trace the
auto-generated framework interfaces.

When we fix sporadic binder calls in the app-startup critical path, we
can remove the restriction and enable tracing more broadly.

Note that we still keep the old behavior of 'best effort' trace names
when binder call stack sampling tracing is enabled

Test: Manual
Bug: 246650647
Change-Id: Id04b701f97241cbd5d14bbb368fdd8527b6f8c93
parent ab23aee0
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -1241,8 +1241,21 @@ public class Binder implements IBinder {
        // If the call was {@link IBinder#FLAG_ONEWAY} then these exceptions
        // If the call was {@link IBinder#FLAG_ONEWAY} then these exceptions
        // disappear into the ether.
        // disappear into the ether.
        final boolean tagEnabled = Trace.isTagEnabled(Trace.TRACE_TAG_AIDL);
        final boolean tagEnabled = Trace.isTagEnabled(Trace.TRACE_TAG_AIDL);
        final boolean hasFullyQualifiedName = getMaxTransactionId() > 0;
        final String transactionTraceName;
        final String transactionTraceName;
        if (tagEnabled) {

        if (tagEnabled && hasFullyQualifiedName) {
            // If tracing enabled and we have a fully qualified name, fetch the name
            transactionTraceName = getTransactionTraceName(code);
        } else if (tagEnabled && isStackTrackingEnabled()) {
            // If tracing is enabled and we *don't* have a fully qualified name, fetch the
            // 'best effort' name only for stack tracking. This works around noticeable perf impact
            // on low latency binder calls (<100us). The tracing call itself is between (1-10us) and
            // the perf impact can be quite noticeable while benchmarking such binder calls.
            // The primary culprits are ContentProviders and Cursors which convenienty don't
            // autogenerate their AIDL and hence will not have a fully qualified name.
            //
            // TODO(b/253426478): Relax this constraint after a more robust fix
            transactionTraceName = getTransactionTraceName(code);
            transactionTraceName = getTransactionTraceName(code);
        } else {
        } else {
            transactionTraceName = null;
            transactionTraceName = null;