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

Commit 28f2e4b4 authored by Jared Duke's avatar Jared Duke
Browse files

Support preload of location/media system libs

These libraries are loaded in ~10% of cold process starts, and
preloading yields modest improvements to both app startup latency
and memory, particularly for lower-end devices.

Add support for preloading these libraries behind a new flag:
  com.android.internal.os.enable_media_and_location_preload

Bug: 241474956
Test: m + ART benchmark service
Test: atest FrameworksCoreTests:android.app.ApplicationLoadersTest
Test: abtd + boottime_test_atrace_debug + boot trace inspection
Flag: com.android.internal.os.enable_media_and_location_preload
Change-Id: Ie75aa0d38555b6e5b71be9d535d58fe328c55893
parent 9e935923
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -429,6 +429,27 @@ public class ZygoteInit {
                    null /*dependentPackages*/, null /*dependencies*/, false /*isNative*/));
        }

        if (Flags.enableMediaAndLocationPreload()) {
            // As these libraries are technically optional and not necessarily inherited from
            // base_system.mk, only cache them if they exist.
            final String mediaJarPath = "/system/framework/com.android.media.remotedisplay.jar";
            if (new File(mediaJarPath).exists()) {
                libs.add(new SharedLibraryInfo(
                        mediaJarPath, null /*packageName*/,
                        null /*codePaths*/, null /*name*/, 0 /*version*/,
                        SharedLibraryInfo.TYPE_BUILTIN, null /*declaringPackage*/,
                        null /*dependentPackages*/, null /*dependencies*/, false /*isNative*/));
            }
            final String locationJarPath = "/system/framework/com.android.location.provider.jar";
            if (new File(locationJarPath).exists()) {
                libs.add(new SharedLibraryInfo(
                        locationJarPath, null /*packageName*/,
                        null /*codePaths*/, null /*name*/, 0 /*version*/,
                        SharedLibraryInfo.TYPE_BUILTIN, null /*declaringPackage*/,
                        null /*dependentPackages*/, null /*dependencies*/, false /*isNative*/));
            }
        }

        // WindowManager Extensions is an optional shared library that is required for WindowManager
        // Jetpack to fully function. Since it is a widely used library, preload it to improve apps
        // startup performance.
+7 −0
Original line number Diff line number Diff line
@@ -52,6 +52,13 @@ flag {
    bug: "241474956"
}

flag {
    name: "enable_media_and_location_preload"
    namespace: "system_performance"
    description: "Enables zygote preload of non-BCP media and location libraries."
    bug: "241474956"
}

flag {
    name: "use_transaction_codes_for_unknown_methods"
    namespace: "stability"