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

Commit 6d016234 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Improve Transition GC initiation by improving the Frameworks...

Merge "Merge "Improve Transition GC initiation by improving the Frameworks triggering signal" am: 9c6a8eb6 am: 832afca2 am: 2d87e627 am: f7e5e147 am: 9c06de5e"
parents 51c7a14e 2d2f2156
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -3557,8 +3557,13 @@ public final class ActivityThread extends ClientTransactionHandler
            if (mLastProcessState == processState) {
                return;
            }
            mLastProcessState = processState;
            // Do not issue a transitional GC if we are transitioning between 2 cached states.
            // Only update if the state flips between cached and uncached or vice versa
            if (ActivityManager.isProcStateCached(mLastProcessState)
                    != ActivityManager.isProcStateCached(processState)) {
                updateVmProcessState(processState);
            }
            mLastProcessState = processState;
            if (localLOGV) {
                Slog.i(TAG, "******************* PROCESS STATE CHANGED TO: " + processState
                        + (fromIpc ? " (from ipc" : ""));
@@ -3567,12 +3572,16 @@ public final class ActivityThread extends ClientTransactionHandler
    }

    /** Update VM state based on ActivityManager.PROCESS_STATE_* constants. */
    // Currently ART VM only uses state updates for Transitional GC, and thus
    // this function initiates a Transitional GC for transitions into Cached apps states.
    private void updateVmProcessState(int processState) {
        // TODO: Tune this since things like gmail sync are important background but not jank
        // perceptible.
        final int state = processState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND
                ? VM_PROCESS_STATE_JANK_PERCEPTIBLE
                : VM_PROCESS_STATE_JANK_IMPERCEPTIBLE;
        // Only a transition into Cached state should result in a Transitional GC request
        // to the ART runtime. Update VM state to JANK_IMPERCEPTIBLE in that case.
        // Note that there are 4 possible cached states currently, all of which are
        // JANK_IMPERCEPTIBLE from GC point of view.
        final int state = ActivityManager.isProcStateCached(processState)
                ? VM_PROCESS_STATE_JANK_IMPERCEPTIBLE
                : VM_PROCESS_STATE_JANK_PERCEPTIBLE;
        VMRuntime.getRuntime().updateProcessState(state);
    }