From ced7e08129902f007afa7a87bdcf5a122fd67658 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Mon, 4 Feb 2019 13:28:36 -0800 Subject: [PATCH] Add use_app_image_startup_cache feature flag Passed down to the zygote if the corresponding system property is set: runtime_native / use_app_image_startup_cache. Bug: 123524494 Bug: 116059983 Test: adb shell device_config put runtime_native use_app_image_startup_cache true Change-Id: I27c0b9ea9533b2b6ad1ccd45f0fb9292c4cfca02 --- core/java/com/android/internal/os/Zygote.java | 5 +++++ core/java/com/android/internal/os/ZygoteInit.java | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index b881aef221ced..8b669d5db8df3 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -99,6 +99,11 @@ public final class Zygote { */ public static final int PROFILE_FROM_SHELL = 1 << 15; + /* + * Enable using the ART app image startup cache + */ + public static final int USE_APP_IMAGE_STARTUP_CACHE = 1 << 16; + /** No external storage should be mounted. */ public static final int MOUNT_EXTERNAL_NONE = IVold.REMOUNT_MODE_NONE; /** Default external storage should be mounted. */ diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 9f23797d6cccd..e132abd7e4cb7 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -41,6 +41,7 @@ import android.system.OsConstants; import android.system.StructCapUserData; import android.system.StructCapUserHeader; import android.text.Hyphenator; +import android.text.TextUtils; import android.util.EventLog; import android.util.Log; import android.util.Slog; @@ -84,6 +85,8 @@ public class ZygoteInit { private static final String PROPERTY_DISABLE_OPENGL_PRELOADING = "ro.zygote.disable_gl_preload"; private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0"; + private static final String PROPERTY_USE_APP_IMAGE_STARTUP_CACHE = + "persist.device_config.runtime_native.use_app_image_startup_cache"; private static final int LOG_BOOT_PROGRESS_PRELOAD_START = 3020; private static final int LOG_BOOT_PROGRESS_PRELOAD_END = 3030; @@ -705,6 +708,13 @@ public class ZygoteInit { parsedArgs.mRuntimeFlags |= Zygote.PROFILE_SYSTEM_SERVER; } + String use_app_image_cache = SystemProperties.get( + PROPERTY_USE_APP_IMAGE_STARTUP_CACHE, ""); + // Property defaults to true currently. + if (!TextUtils.isEmpty(use_app_image_cache) && !use_app_image_cache.equals("false")) { + parsedArgs.mRuntimeFlags |= Zygote.USE_APP_IMAGE_STARTUP_CACHE; + } + /* Request to fork the system server process */ pid = Zygote.forkSystemServer( parsedArgs.mUid, parsedArgs.mGid,