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

Commit 275294db authored by Narayan Kamath's avatar Narayan Kamath Committed by Android (Google) Code Review
Browse files

Merge "Better systrace slices for application startup." into mnc-dev

parents 19769114 fbb32f64
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -90,9 +90,6 @@ public:


    virtual void onZygoteInit()
    virtual void onZygoteInit()
    {
    {
        // Re-enable tracing now that we're no longer in Zygote.
        atrace_set_tracing_enabled(true);

        sp<ProcessState> proc = ProcessState::self();
        sp<ProcessState> proc = ProcessState::self();
        ALOGV("App process: starting thread pool.\n");
        ALOGV("App process: starting thread pool.\n");
        proc->startThreadPool();
        proc->startThreadPool();
+3 −0
Original line number Original line Diff line number Diff line
@@ -5375,6 +5375,7 @@ public final class ActivityThread {
    }
    }


    public static void main(String[] args) {
    public static void main(String[] args) {
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ActivityThreadMain");
        SamplingProfilerIntegration.start();
        SamplingProfilerIntegration.start();


        // CloseGuard defaults to true and can be quite spammy.  We
        // CloseGuard defaults to true and can be quite spammy.  We
@@ -5409,6 +5410,8 @@ public final class ActivityThread {
                    LogPrinter(Log.DEBUG, "ActivityThread"));
                    LogPrinter(Log.DEBUG, "ActivityThread"));
        }
        }


        // End of event ActivityThreadMain.
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
        Looper.loop();
        Looper.loop();


        throw new RuntimeException("Main thread loop unexpectedly exited");
        throw new RuntimeException("Main thread loop unexpectedly exited");
+5 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Debug;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Process;
import android.os.Process;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.Trace;
import android.util.Log;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;
import com.android.internal.logging.AndroidConfig;
import com.android.internal.logging.AndroidConfig;
@@ -269,11 +270,11 @@ public class RuntimeInit {
            throws ZygoteInit.MethodAndArgsCaller {
            throws ZygoteInit.MethodAndArgsCaller {
        if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application from zygote");
        if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application from zygote");


        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "RuntimeInit");
        redirectLogStreams();
        redirectLogStreams();


        commonInit();
        commonInit();
        nativeZygoteInit();
        nativeZygoteInit();

        applicationInit(targetSdkVersion, argv, classLoader);
        applicationInit(targetSdkVersion, argv, classLoader);
    }
    }


@@ -318,6 +319,9 @@ public class RuntimeInit {
            return;
            return;
        }
        }


        // The end of of the RuntimeInit event (see #zygoteInit).
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

        // Remaining arguments are passed to the start class's static main
        // Remaining arguments are passed to the start class's static main
        invokeStaticMain(args.startClass, args.startArgs, classLoader);
        invokeStaticMain(args.startClass, args.startArgs, classLoader);
    }
    }
+12 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.os;
package com.android.internal.os;




import android.os.Trace;
import dalvik.system.ZygoteHooks;
import dalvik.system.ZygoteHooks;
import android.system.ErrnoException;
import android.system.ErrnoException;
import android.system.Os;
import android.system.Os;
@@ -88,6 +89,13 @@ public final class Zygote {
        int pid = nativeForkAndSpecialize(
        int pid = nativeForkAndSpecialize(
                  uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
                  uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
                  instructionSet, appDataDir);
                  instructionSet, appDataDir);
        // Enable tracing as soon as possible for the child process.
        if (pid == 0) {
            Trace.setTracingEnabled(true);

            // Note that this event ends at the end of handleChildProc,
            Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork");
        }
        VM_HOOKS.postForkCommon();
        VM_HOOKS.postForkCommon();
        return pid;
        return pid;
    }
    }
@@ -124,6 +132,10 @@ public final class Zygote {
        VM_HOOKS.preFork();
        VM_HOOKS.preFork();
        int pid = nativeForkSystemServer(
        int pid = nativeForkSystemServer(
                uid, gid, gids, debugFlags, rlimits, permittedCapabilities, effectiveCapabilities);
                uid, gid, gids, debugFlags, rlimits, permittedCapabilities, effectiveCapabilities);
        // Enable tracing as soon as we enter the system_server.
        if (pid == 0) {
            Trace.setTracingEnabled(true);
        }
        VM_HOOKS.postForkCommon();
        VM_HOOKS.postForkCommon();
        return pid;
        return pid;
    }
    }
+3 −1
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.net.LocalSocket;
import android.os.Process;
import android.os.Process;
import android.os.SELinux;
import android.os.SELinux;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.Trace;
import android.system.ErrnoException;
import android.system.ErrnoException;
import android.system.Os;
import android.system.Os;
import android.util.Log;
import android.util.Log;
@@ -711,7 +712,6 @@ class ZygoteConnection {
    private void handleChildProc(Arguments parsedArgs,
    private void handleChildProc(Arguments parsedArgs,
            FileDescriptor[] descriptors, FileDescriptor pipeFd, PrintStream newStderr)
            FileDescriptor[] descriptors, FileDescriptor pipeFd, PrintStream newStderr)
            throws ZygoteInit.MethodAndArgsCaller {
            throws ZygoteInit.MethodAndArgsCaller {

        /**
        /**
         * By the time we get here, the native code has closed the two actual Zygote
         * By the time we get here, the native code has closed the two actual Zygote
         * socket connections, and substituted /dev/null in their place.  The LocalSocket
         * socket connections, and substituted /dev/null in their place.  The LocalSocket
@@ -740,6 +740,8 @@ class ZygoteConnection {
            Process.setArgV0(parsedArgs.niceName);
            Process.setArgV0(parsedArgs.niceName);
        }
        }


        // End of the postFork event.
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
        if (parsedArgs.invokeWith != null) {
        if (parsedArgs.invokeWith != null) {
            WrapperInit.execApplication(parsedArgs.invokeWith,
            WrapperInit.execApplication(parsedArgs.invokeWith,
                    parsedArgs.niceName, parsedArgs.targetSdkVersion,
                    parsedArgs.niceName, parsedArgs.targetSdkVersion,