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

Commit 12d2a30a authored by Adam Bookatz's avatar Adam Bookatz
Browse files

Multiuser perfetto metric: adb tracepoints

Add tracepoints in adb for user switches and creation, for the
primary purpose of performance metrics in trace_processor.

These need to be done at the level of shell, not
UserController/UserManager because each entrypoint needs an explicit
tracepoint.
We already have some for UI-based entrypoints - and we want to time
from the moment
the user requests the switch, not some internal point that might be
substantially later - so to capture adb-based switching/creation within
the same trace processor mechanism, we must also add tracepoints for
the shell commands.

Bug: 192001071
Test: manual
Change-Id: I2d7d30faf7906eb455f5d2dc05f0d6b2d96518c2
parent 2cb01877
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import android.os.ShellCommand;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
@@ -1880,6 +1881,8 @@ final class ActivityManagerShellCommand extends ShellCommand {

        int userId = Integer.parseInt(getNextArgRequired());
        boolean switched;
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "shell_runSwitchUser");
        try {
            if (wait) {
                switched = switchUserAndWaitForComplete(userId);
            } else {
@@ -1891,6 +1894,9 @@ final class ActivityManagerShellCommand extends ShellCommand {
                pw.printf("Error: Failed to switch to user %d\n", userId);
                return 1;
            }
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
        }
    }

    int runGetCurrentUser(PrintWriter pw) throws RemoteException {
+1 −1
Original line number Diff line number Diff line
@@ -1373,7 +1373,7 @@ class UserController implements Handler.Callback {
            @Nullable IProgressListener unlockListener) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog();

        t.traceBegin("startUser-" + userId + "-" + (foreground ? "fg" : "bg"));
        t.traceBegin("UserController.startUser-" + userId + "-" + (foreground ? "fg" : "bg"));
        try {
            return startUserInternal(userId, foreground, unlockListener, t);
        } finally {
+4 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import android.os.ServiceSpecificException;
import android.os.ShellCommand;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.incremental.V4Signature;
@@ -2629,6 +2630,7 @@ class PackageManagerShellCommand extends ShellCommand {
        if (userType == null) {
            userType = UserInfo.getDefaultUserType(flags);
        }
        Trace.traceBegin(Trace.TRACE_TAG_PACKAGE_MANAGER, "shell_runCreateUser");
        try {
            if (UserManager.isUserTypeRestricted(userType)) {
                // In non-split user mode, userId can only be SYSTEM
@@ -2645,6 +2647,8 @@ class PackageManagerShellCommand extends ShellCommand {
            }
        } catch (ServiceSpecificException e) {
            getErrPrintWriter().println("Error: " + e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_PACKAGE_MANAGER);
        }

        if (info != null) {