Zygote: Reset niceness if lazy preloading is enabled.
By definition, the zygote in question is lower priority if lazy
preloading is enabled. We therefore reset the zygote process'
niceness to 0 as soon as it comes up, rather than having it stick
around as a higher priority process until we eventually ask it
to load the default set of resources.
Test: manual.
Change-Id: I3ccfc0e7c3fdebf5f798d90b53140a554bf64c20
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 59416dd..fa71a62 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -173,6 +173,10 @@
VM_HOOKS.postForkChild(debugFlags, isSystemServer, instructionSet);
}
+ /**
+ * Resets this process' priority to the default value (0).
+ */
+ native static void nativeResetNicePriority();
/**
* Executes "/system/bin/sh -c <command>" using the exec() system call.
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index a72b66a..1fb31b4 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -712,6 +712,8 @@
EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END,
SystemClock.uptimeMillis());
bootTimingsTraceLog.traceEnd(); // ZygotePreload
+ } else {
+ Zygote.nativeResetNicePriority();
}
// Finish profiling the zygote initialization.