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

Commit f11a9628 authored by Jared Duke's avatar Jared Duke
Browse files

Add flag-guarded disabling of default .art file madvise

The compressed .art app image file is read just once during process
startup. As such, there is little benefit to running a full madvise
before starting decompression, and in some cases this actually leads
to (slightly) worse latency.

Use a flag to control the default value for the ART runtime's
`-XMadviseWillNeedArtFileSize` configuration. Previously, this
was set via a makefile default to be UINT_MAX. This default is preserved
in the runtime, where the new aconfig flag disables this default
and turns off .art file madvise (unless the property is explicitly
configured for a particular device).

After ramping and validating performance impact, we may consider
deprecating and removing this ART runtime flag completely.

Flag: android.os.disable_madvise_artfile_default
Test: m
Test: adb shell aflags enable android.os.disable_madvise_artfile_default
   && adb shell setprop dalvik.vm.extra-opts -verbose:startup
   && adb logcat | grep Madvise
Bug: 382110550
Change-Id: I16170215da0d06a0fd110112fc17b03002939621
parent 9b20ff48
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -288,6 +288,7 @@ cc_library_shared_for_libandroid_runtime {
            ],

            static_libs: [
                "android.os.flags-aconfig-cc",
                "libasync_safe",
                "libbinderthreadstateutils",
                "libdmabufinfo",
+8 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <android-base/parsebool.h>
#include <android-base/properties.h>
#include <android/graphics/jni_runtime.h>
#include <android_os.h>
#include <android_runtime/AndroidRuntime.h>
#include <assert.h>
#include <binder/IBinder.h>
@@ -887,9 +888,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p
                       madviseWillNeedFileSizeOdex,
                       "-XMadviseWillNeedOdexFileSize:");

    parseRuntimeOption("dalvik.vm.madvise.artfile.size",
                       madviseWillNeedFileSizeArt,
                       "-XMadviseWillNeedArtFileSize:");
    // Historically, dalvik.vm.madvise.artfile.size was set to UINT_MAX by default. With the
    // disable_madvise_art_default flag rollout, we use this default only when the flag is disabled.
    // TODO(b/382110550): Remove this property/flag entirely after validating and ramping.
    const char* madvise_artfile_size_default =
            android::os::disable_madvise_artfile_default() ? "" : "4294967295";
    parseRuntimeOption("dalvik.vm.madvise.artfile.size", madviseWillNeedFileSizeArt,
                       "-XMadviseWillNeedArtFileSize:", madvise_artfile_size_default);

    /*
     * Profile related options.