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

Commit 96e75fca authored by Abhimanyu Garg's avatar Abhimanyu Garg 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: Id6d3fc37509631bf476b2a27dfe45381f4086dc1
parent be9c0764
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;
    }

};
+12 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import android.util.ArraySet;
import android.util.DebugUtils;
import android.util.SparseIntArray;
import android.view.Display;
import android.util.BoostFramework;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
@@ -3359,6 +3360,17 @@ public final class ActivityManagerService extends ActivityManagerNative
            checkTime(startTime, "startProcess: building log message");
            StringBuilder buf = mStringBuilder;
            buf.setLength(0);
            if(hostingType.equals("activity"))
            {
                BoostFramework mPerf = null;
                if (null == mPerf) {
                    mPerf = new BoostFramework();
                }
                if (mPerf != null) {
                    mPerf.perfIOPrefetchStart(startResult.pid,app.processName);
                }
            }
            buf.append("Start proc ");
            buf.append(startResult.pid);
            buf.append(':');
+16 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
    static final int SLEEP_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 3;
    static final int LAUNCH_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 4;
    public BoostFramework mPerf = null;
    public BoostFramework mPerf_iop = null;
    public boolean mIsPerfBoostEnabled = false;
    public int lBoostTimeOut = 0;
    public int lDisPackTimeOut = 0;
@@ -3091,6 +3092,14 @@ public final class ActivityStackSupervisor implements DisplayListener {
                    if(ar.state == ActivityState.DESTROYED ) {
                        /*It's a new app launch */
                        acquireAppLaunchPerfLock();

                        // Strat IOP
                        if (mPerf_iop == null) {
                            mPerf_iop = new BoostFramework();
                        }
                        if (mPerf_iop != null) {
                            mPerf_iop.perfIOPrefetchStart(-1,r.packageName);
                        }
                    }
                    return ar;
                }
@@ -3098,6 +3107,13 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
        /* Acquire perf lock during new app launch */
        acquireAppLaunchPerfLock();
        //Start IOP
        if (mPerf_iop == null) {
            mPerf_iop = new BoostFramework();
        }
        if (mPerf_iop != null) {
            mPerf_iop.perfIOPrefetchStart(-1,r.packageName);
        }

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