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

Commit c35293c3 authored by Bhargav Upperla's avatar Bhargav Upperla Committed by Linux Build Service Account
Browse files

Framework for LaunchBoost v2 and Frequency aggr during launch.

Extending original launch boost to
benefit apps that take more than 2 secs
to finish launch.

This is improved in two different ways.
1) Frequency aggregation during launching a
large app.
(Ex: Templerun2 launch latency improves by 5 secs)

2) LaunchBoost v2 to set various sched params
or cpu sets during launch of a large app.

Both perflocks are a more light weight boost
without any cpu boosts and shows good benefit to
large app launch latencies.
(Ex: Games)

Also responds to user touch as one form to indicate
end of launch and stop boosts.

Change-Id: Ie704c084104237e39b30659357667a5ebee7da36
parent 2ad9e1d1
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2488,6 +2488,17 @@
    <integer name="launchboost_timeout_param">0</integer>
    <integer-array name="launchboost_param_value"/>

    <!-- Whether cpu freq aggr is enabled for AppLaunch -->
    <bool name="config_enableLaunchBoostv2">false</bool>
    <integer name="lboostv2_timeout_param">0</integer>
    <integer-array name="lboostv2_param_value"/>

    <!-- Whether cpu freq aggr is enabled for AppLaunch -->
    <bool name="config_enableFreqAggr">false</bool>
    <integer name="freqaggr_timeout_param">0</integer>
    <integer-array name="freqaggr_init_param_value"/>
    <integer-array name="freqaggr_param_value"/>

    <!-- Whether disablepacking is enabled or not -->
    <bool name="config_disablePacking">false</bool>
    <integer name="disablepacking_timeout_param">0</integer>
+11 −0
Original line number Diff line number Diff line
@@ -2638,6 +2638,17 @@
  <java-symbol type="integer" name="launchboost_timeout_param" />
  <java-symbol type="array" name="launchboost_param_value" />

  <!-- cpu boost v2 for Applaunch -->
  <java-symbol type="bool" name="config_enableLaunchBoostv2" />
  <java-symbol type="integer" name="lboostv2_timeout_param" />
  <java-symbol type="array" name="lboostv2_param_value" />

  <!-- freq aggr for Applaunch -->
  <java-symbol type="bool" name="config_enableFreqAggr" />
  <java-symbol type="integer" name="freqaggr_timeout_param" />
  <java-symbol type="array" name="freqaggr_init_param_value" />
  <java-symbol type="array" name="freqaggr_param_value" />

  <!-- cpu boost for AppLaunch -->
  <java-symbol type="bool" name="config_disablePacking" />
  <java-symbol type="integer" name="disablepacking_timeout_param" />
+68 −0
Original line number Diff line number Diff line
@@ -555,6 +555,22 @@ public final class ActivityManagerService extends ActivityManagerNative
    private boolean mIsBoosted = false;
    private long mBoostStartTime = 0;
    /* Freq Aggr boost objects */
    public static BoostFramework sFreqAggr_init = null;
    public static BoostFramework sFreqAggr = null;
    public static boolean sIsFreqAggrBoostSet = false;
    private boolean mIsFreqAggrEnabled = false;
    private int lFreqAggr_TimeOut = 0;
    private int lFreqAggr_Init_ParamVal[];
    private int lFreqAggr_ParamVal[];
    /* Launch boost v2 objects */
    public static BoostFramework sPerfBoost_v2 = null;
    public static boolean sIsLaunchBoostv2_set = false;
    private boolean mIsLaunchBoostv2_enabled = false;
    private int lBoost_v2_TimeOut = 0;
    private int lBoost_v2_ParamVal[];
    /** All system services */
    SystemServiceManager mSystemServiceManager;
@@ -2713,6 +2729,28 @@ public final class ActivityManagerService extends ActivityManagerNative
        Watchdog.getInstance().addMonitor(this);
        Watchdog.getInstance().addThread(mHandler);
        mIsFreqAggrEnabled = mContext.getResources().getBoolean(
                   com.android.internal.R.bool.config_enableFreqAggr);
        if(mIsFreqAggrEnabled) {
           lFreqAggr_TimeOut = mContext.getResources().getInteger(
                   com.android.internal.R.integer.freqaggr_timeout_param);
           lFreqAggr_Init_ParamVal = mContext.getResources().getIntArray(
                   com.android.internal.R.array.freqaggr_init_param_value);
           lFreqAggr_ParamVal = mContext.getResources().getIntArray(
                   com.android.internal.R.array.freqaggr_param_value);
        }
        mIsLaunchBoostv2_enabled = mContext.getResources().getBoolean(
                   com.android.internal.R.bool.config_enableLaunchBoostv2);
        if(mIsLaunchBoostv2_enabled) {
           lBoost_v2_TimeOut = mContext.getResources().getInteger(
                   com.android.internal.R.integer.lboostv2_timeout_param);
           lBoost_v2_ParamVal = mContext.getResources().getIntArray(
                   com.android.internal.R.array.lboostv2_param_value);
        }
    }
    public void setSystemServiceManager(SystemServiceManager mgr) {
@@ -3845,6 +3883,36 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (perf != null) {
                    perf.perfIOPrefetchStart(startResult.pid,app.processName);
                }
                // Start Freq Aggregation boost
                if (mIsFreqAggrEnabled == true && sFreqAggr_init == null
                    && sFreqAggr == null) {
                   sFreqAggr_init = new BoostFramework();
                   sFreqAggr = new BoostFramework();
                }
                if (sFreqAggr_init != null && sFreqAggr != null) {
                   sFreqAggr_init.perfLockAcquire(lFreqAggr_TimeOut, lFreqAggr_Init_ParamVal);
                   sIsFreqAggrBoostSet = true;
                   // Frequency Aggr perflock can only be passed one opcode-pair
                   if (lFreqAggr_ParamVal.length == 2) {
                       lFreqAggr_ParamVal[1] = startResult.pid;
                       sFreqAggr.perfLockAcquire(lFreqAggr_TimeOut, lFreqAggr_ParamVal);
                   } else {
                       //Opcodes improperly defined. Disable Perflock FA support.
                       sFreqAggr = null;
                       sFreqAggr_init.perfLockRelease();
                       sIsFreqAggrBoostSet = false;
                   }
                }
                // Start launch boost v2
                if (mIsLaunchBoostv2_enabled == true && sPerfBoost_v2 == null) {
                    sPerfBoost_v2 = new BoostFramework();
                }
                if (sPerfBoost_v2 != null) {
                   sPerfBoost_v2.perfLockAcquire(lBoost_v2_TimeOut, lBoost_v2_ParamVal);
                   sIsLaunchBoostv2_set = true;
                }
            }
            app.setPid(startResult.pid);
+12 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.MotionEvent;
import android.view.WindowManagerPolicy.PointerEventListener;

import com.android.server.wm.WindowManagerService.H;
import com.android.server.am.ActivityManagerService;

import static android.view.PointerIcon.TYPE_NOT_SPECIFIED;
import static android.view.PointerIcon.TYPE_DEFAULT;
@@ -63,6 +64,17 @@ public class TaskTapPointerEventListener implements PointerEventListener {
    public void onPointerEvent(MotionEvent motionEvent) {
        doGestureDetection(motionEvent);

        if (ActivityManagerService.sIsFreqAggrBoostSet) {
            ActivityManagerService.sFreqAggr_init.perfLockRelease();
            ActivityManagerService.sFreqAggr.perfLockRelease();
            ActivityManagerService.sIsFreqAggrBoostSet = false;
        }

        if (ActivityManagerService.sIsLaunchBoostv2_set) {
            ActivityManagerService.sPerfBoost_v2.perfLockRelease();
            ActivityManagerService.sIsLaunchBoostv2_set = false;
        }

        final int action = motionEvent.getAction();
        switch (action & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN: {