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

Commit 53128e41 authored by Jing Ji's avatar Jing Ji Committed by Android (Google) Code Review
Browse files

Merge "Defer the Pss sampling on app processes post the boot" into main

parents b8c002f0 bf61ebd3
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -1532,6 +1532,11 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    int mBootPhase;
    /**
     * The time stamp that all apps have received BOOT_COMPLETED.
     */
    volatile long mBootCompletedTimestamp;
    @GuardedBy("this")
    boolean mDeterministicUidIdle = false;
@@ -5164,10 +5169,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                        public void performReceive(Intent intent, int resultCode,
                                String data, Bundle extras, boolean ordered,
                                boolean sticky, int sendingUser) {
                            mBootCompletedTimestamp = SystemClock.uptimeMillis();
                            // Defer the full Pss collection as the system is really busy now.
                            mHandler.postDelayed(() -> {
                                synchronized (mProcLock) {
                                    mAppProfiler.requestPssAllProcsLPr(
                                            SystemClock.uptimeMillis(), true, false);
                                }
                            }, mConstants.FULL_PSS_MIN_INTERVAL);
                        }
                    });
            maybeLogUserspaceRebootEvent();
+2 −2
Original line number Diff line number Diff line
@@ -1439,7 +1439,7 @@ public final class ProcessList {
    }

    public static long computeNextPssTime(int procState, ProcStateMemTracker tracker, boolean test,
            boolean sleeping, long now) {
            boolean sleeping, long now, long earliest) {
        boolean first;
        float scalingFactor;
        final int memState = sProcStateToProcMem[procState];
@@ -1470,7 +1470,7 @@ public final class ProcessList {
        if (delay > PSS_MAX_INTERVAL) {
            delay = PSS_MAX_INTERVAL;
        }
        return now + delay;
        return Math.max(now + delay, earliest);
    }

    long getMemLevel(int adjustment) {
+5 −1
Original line number Diff line number Diff line
@@ -575,7 +575,11 @@ final class ProcessProfileRecord {

    @GuardedBy("mProfilerLock")
    long computeNextPssTime(int procState, boolean test, boolean sleeping, long now) {
        return ProcessList.computeNextPssTime(procState, mProcStateMemTracker, test, sleeping, now);
        return ProcessList.computeNextPssTime(procState, mProcStateMemTracker, test, sleeping, now,
                // Cap the Pss time to make sure no Pss is collected during the very few
                // minutes after the system is boot, given the system is already busy.
                Math.max(mService.mBootCompletedTimestamp, mService.mLastIdleTime)
                + mService.mConstants.FULL_PSS_MIN_INTERVAL);
    }

    private static void commitNextPssTime(ProcStateMemTracker tracker) {