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

Commit 880721b3 authored by Alan Leung's avatar Alan Leung Committed by Jean-Philippe Lesot
Browse files

Enable boost-locked-region-priority

Enable jack.transformations.boost-locked-region-priority compiler pass
that had shown to increase performance in AmSlam by 10% or so.

bug: 28610549
Change-Id: If1b76787acd272882647ede7e831cb1ba376e578
parent 005f9a73
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -24,4 +24,10 @@ ifneq ($(INCREMENTAL_BUILDS),)
    LOCAL_JACK_ENABLED := incremental
endif

LOCAL_JACK_FLAGS := \
 -D jack.transformations.boost-locked-region-priority=true \
 -D jack.transformations.boost-locked-region-priority.classname=com.android.server.am.ActivityManagerService \
 -D jack.transformations.boost-locked-region-priority.request=com.android.server.am.ActivityManagerService\#boostPriorityForLockedSection \
 -D jack.transformations.boost-locked-region-priority.reset=com.android.server.am.ActivityManagerService\#resetPriorityAfterLockedSection

include $(BUILD_STATIC_JAVA_LIBRARY)
+24 −0
Original line number Diff line number Diff line
@@ -628,6 +628,30 @@ public final class ActivityManagerService extends ActivityManagerNative
        return mShowDialogs && !mSleeping && !mShuttingDown;
    }
    // it's a semaphore; boost when 0->1, reset when 1->0
    static ThreadLocal<Integer> sIsBoosted = new ThreadLocal<Integer>() {
        @Override protected Integer initialValue() {
            return 0;
        }
    };
    static void boostPriorityForLockedSection() {
        if (sIsBoosted.get() == 0) {
            // boost to prio 118 while holding a global lock
            Process.setThreadPriority(Process.myTid(), -2);
            //Log.e(TAG, "PRIORITY BOOST:  set priority on TID " + Process.myTid());
        }
        int cur = sIsBoosted.get();
        sIsBoosted.set(cur + 1);
    }
    static void resetPriorityAfterLockedSection() {
        sIsBoosted.set(sIsBoosted.get() - 1);
        if (sIsBoosted.get() == 0) {
            //Log.e(TAG, "PRIORITY BOOST:  reset priority on TID " + Process.myTid());
            Process.setThreadPriority(Process.myTid(), 0);
        }
    }
    public class PendingAssistExtras extends Binder implements Runnable {
        public final ActivityRecord activity;
        public final Bundle extras;