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

Commit 911884e1 authored by Omprakash Dhyade's avatar Omprakash Dhyade Committed by Linux Build Service Account
Browse files

Perf: Adding hooks for IO prefetcher into framework

Adding function call to start the io prefetcher
during application launch.

Change-Id: I6268538e3d0ee7632c6e01dc14732bb7914f337b
parent f56206d6
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ public class BoostFramework {
    private static Method mAcquireFunc = null;
    private static Method mReleaseFunc = null;
    private static Method mAcquireTouchFunc = null;
    private static Method mIOPStart = null;
    private static Method mIOPStop  = null;
    private static Constructor<Class> mConstructor = null;

/** @hide */
@@ -79,6 +81,14 @@ public class BoostFramework {
                mAcquireTouchFunc =  perfClass.getDeclaredMethod("perfLockAcquireTouch", argClasses);
                Log.v(TAG,"mAcquireTouchFunc method = " + mAcquireTouchFunc);

                argClasses = new Class[] {int.class, String.class};
                mIOPStart =  perfClass.getDeclaredMethod("perfIOPrefetchStart", argClasses);
                Log.v(TAG,"mIOPStart method = " + mIOPStart);

                argClasses = new Class[] {};
                mIOPStop =  perfClass.getDeclaredMethod("perfIOPrefetchStop", argClasses);
                Log.v(TAG,"mIOPStop method = " + mIOPStop);

                mIsLoaded = true;
            }
            catch(Exception e) {
@@ -145,4 +155,30 @@ public class BoostFramework {
        return ret;
    }

/** @hide */
    public int perfIOPrefetchStart(int pid, String pkg_name)
    {
        int ret = -1;
        try {
            Object retVal = mIOPStart.invoke(mPerf,pid,pkg_name);
            ret = (int)retVal;
        } catch(Exception e) {
            Log.e(TAG,"Exception " + e);
        }
        return ret;
    }

/** @hide */
    public int perfIOPrefetchStop()
    {
        int ret = -1;
         try {
             Object retVal = mIOPStop.invoke(mPerf);
             ret = (int)retVal;
         } catch(Exception e) {
             Log.e(TAG,"Exception " + e);
         }
         return ret;
    }

};
+10 −0
Original line number Diff line number Diff line
@@ -216,6 +216,7 @@ import android.util.Slog;
import android.util.SparseArray;
import android.util.TimeUtils;
import android.util.Xml;
import android.util.BoostFramework;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -3834,6 +3835,15 @@ public final class ActivityManagerService extends ActivityManagerNative
                buf.append(hostingNameStr);
            }
            Slog.i(TAG, buf.toString());
            if(hostingType.equals("activity")) {
                BoostFramework perf = new BoostFramework();
                if (perf != null) {
                    perf.perfIOPrefetchStart(startResult.pid,app.processName);
                }
            }
            app.setPid(startResult.pid);
            app.usingWrapper = startResult.usingWrapper;
            app.removed = false;
+19 −8
Original line number Diff line number Diff line
@@ -206,14 +206,17 @@ public final class ActivityStackSupervisor implements DisplayListener {
    static final int RESUME_TOP_ACTIVITY_MSG = FIRST_SUPERVISOR_STACK_MSG + 2;
    static final int SLEEP_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 3;
    static final int LAUNCH_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 4;

    public BoostFramework mPerfBoost = null;
    public BoostFramework mPerfPack = null;
    public BoostFramework mPerfIop = null;
    public boolean mIsPerfBoostEnabled = false;
    public boolean mIsperfDisablepackingEnable = false;
    public int lBoostTimeOut = 0;
    public int lDisPackTimeOut = 0;
    public int lBoostCpuParamVal[];
    public int lBoostPackParamVal[];

    static final int HANDLE_DISPLAY_ADDED = FIRST_SUPERVISOR_STACK_MSG + 5;
    static final int HANDLE_DISPLAY_CHANGED = FIRST_SUPERVISOR_STACK_MSG + 6;
    static final int HANDLE_DISPLAY_REMOVED = FIRST_SUPERVISOR_STACK_MSG + 7;
@@ -1873,7 +1876,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        top_activity = task.stack.topRunningActivityLocked();
        /* App is launching from recent apps and it's a new process */
        if(top_activity != null && top_activity.state == ActivityState.DESTROYED) {
            acquireAppLaunchPerfLock();
            acquireAppLaunchPerfLock(top_activity.packageName);
        }

        if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
@@ -2644,7 +2647,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        resumeFocusedStackTopActivityLocked();
    }

    void acquireAppLaunchPerfLock() {
    void acquireAppLaunchPerfLock(String packageName) {
       /* Acquire perf lock during new app launch */
       if (mIsperfDisablepackingEnable == true && mPerfPack == null) {
           mPerfPack = new BoostFramework();
@@ -2659,6 +2662,14 @@ public final class ActivityStackSupervisor implements DisplayListener {
       if (mPerfBoost != null) {
           mPerfBoost.perfLockAcquire(lBoostTimeOut, lBoostCpuParamVal);
       }

       // Start IOP
       if (mPerfIop == null) {
           mPerfIop = new BoostFramework();
       }
       if (mPerfIop != null) {
           mPerfIop.perfIOPrefetchStart(-1,packageName);
       }
    }

    ActivityRecord findTaskLocked(ActivityRecord r) {
@@ -2686,17 +2697,17 @@ public final class ActivityStackSupervisor implements DisplayListener {
                if (mTmpFindTaskResult.r != null && !mTmpFindTaskResult.matchedByRootAffinity) {
                    if(mTmpFindTaskResult.r.state == ActivityState.DESTROYED ) {
                        /*It's a new app launch */
                        acquireAppLaunchPerfLock();
                        acquireAppLaunchPerfLock(r.packageName);
                    }
                    return mTmpFindTaskResult.r;
                }
            }
        }
        /* Acquire perf lock during new app launch */
        if (mTmpFindTaskResult.r == null)
            acquireAppLaunchPerfLock();
        else if (mTmpFindTaskResult.r.state == ActivityState.DESTROYED)
            acquireAppLaunchPerfLock();

        /* Acquire perf lock *only* during new app launch */
        if (mTmpFindTaskResult.r == null || mTmpFindTaskResult.r.state == ActivityState.DESTROYED) {
            acquireAppLaunchPerfLock(r.packageName);
        }

        if (DEBUG_TASKS && mTmpFindTaskResult.r == null) Slog.d(TAG_TASKS, "No task found");
        return mTmpFindTaskResult.r;