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

Commit b66222e1 authored by Kweku Adams's avatar Kweku Adams
Browse files

Reserve contexts for user-initiated jobs.

Bug: 261999509
Test: atest FrameworksMockingServicesTests:JobConcurrencyManagerTest
Test: atest FrameworksServicesTests:BiasSchedulingTest
Test: atest FrameworksServicesTests:WorkCountTrackerTest
Test: atest FrameworksServicesTests:WorkTypeConfigTest
Change-Id: I616d81925f1f67bf051a5648cb3386920c071dc1
parent b3fb718c
Loading
Loading
Loading
Loading
+55 −21
Original line number Diff line number Diff line
@@ -158,33 +158,37 @@ class JobConcurrencyManager {
     * state (excluding {@link ActivityManager#PROCESS_STATE_TOP} for a currently active user.
     */
    static final int WORK_TYPE_FGS = 1 << 1;
    /** The job is allowed to run as a user-initiated job for a currently active user. */
    static final int WORK_TYPE_UI = 1 << 2;
    /** The job is allowed to run as an expedited job for a currently active user. */
    static final int WORK_TYPE_EJ = 1 << 2;
    static final int WORK_TYPE_EJ = 1 << 3;
    /**
     * The job does not satisfy any of the conditions for {@link #WORK_TYPE_TOP},
     * {@link #WORK_TYPE_FGS}, or {@link #WORK_TYPE_EJ}, but is for a currently active user, so
     * can run as a background job.
     */
    static final int WORK_TYPE_BG = 1 << 3;
    static final int WORK_TYPE_BG = 1 << 4;
    /**
     * The job is for an app in a {@link ActivityManager#PROCESS_STATE_FOREGROUND_SERVICE} or higher
     * state, or is allowed to run as an expedited job, but is for a completely background user.
     * state, or is allowed to run as an expedited or user-initiated job,
     * but is for a completely background user.
     */
    static final int WORK_TYPE_BGUSER_IMPORTANT = 1 << 4;
    static final int WORK_TYPE_BGUSER_IMPORTANT = 1 << 5;
    /**
     * The job does not satisfy any of the conditions for {@link #WORK_TYPE_TOP},
     * {@link #WORK_TYPE_FGS}, or {@link #WORK_TYPE_EJ}, but is for a completely background user,
     * so can run as a background user job.
     */
    static final int WORK_TYPE_BGUSER = 1 << 5;
    static final int WORK_TYPE_BGUSER = 1 << 6;
    @VisibleForTesting
    static final int NUM_WORK_TYPES = 6;
    static final int NUM_WORK_TYPES = 7;
    private static final int ALL_WORK_TYPES = (1 << NUM_WORK_TYPES) - 1;

    @IntDef(prefix = {"WORK_TYPE_"}, flag = true, value = {
            WORK_TYPE_NONE,
            WORK_TYPE_TOP,
            WORK_TYPE_FGS,
            WORK_TYPE_UI,
            WORK_TYPE_EJ,
            WORK_TYPE_BG,
            WORK_TYPE_BGUSER_IMPORTANT,
@@ -203,6 +207,8 @@ class JobConcurrencyManager {
                return "TOP";
            case WORK_TYPE_FGS:
                return "FGS";
            case WORK_TYPE_UI:
                return "UI";
            case WORK_TYPE_EJ:
                return "EJ";
            case WORK_TYPE_BG:
@@ -238,8 +244,9 @@ class JobConcurrencyManager {
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, .4f),
                                    Pair.create(WORK_TYPE_FGS, .2f),
                                    Pair.create(WORK_TYPE_EJ, .2f), Pair.create(WORK_TYPE_BG, .1f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f)),
                                    Pair.create(WORK_TYPE_UI, .1f),
                                    Pair.create(WORK_TYPE_EJ, .1f), Pair.create(WORK_TYPE_BG, .05f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .05f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, .5f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .25f),
@@ -250,6 +257,7 @@ class JobConcurrencyManager {
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, .4f),
                                    Pair.create(WORK_TYPE_FGS, .1f),
                                    Pair.create(WORK_TYPE_UI, .1f),
                                    Pair.create(WORK_TYPE_EJ, .1f), Pair.create(WORK_TYPE_BG, .1f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f)),
                            // defaultMax
@@ -260,8 +268,9 @@ class JobConcurrencyManager {
                    new WorkTypeConfig("screen_on_low", DEFAULT_CONCURRENCY_LIMIT,
                            /* defaultMaxTotal */  DEFAULT_CONCURRENCY_LIMIT * 4 / 10,
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, 2.0f / 3),
                            List.of(Pair.create(WORK_TYPE_TOP, .6f),
                                    Pair.create(WORK_TYPE_FGS, .1f),
                                    Pair.create(WORK_TYPE_UI, .1f),
                                    Pair.create(WORK_TYPE_EJ, .1f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, 1.0f / 3),
@@ -271,9 +280,10 @@ class JobConcurrencyManager {
                    new WorkTypeConfig("screen_on_critical", DEFAULT_CONCURRENCY_LIMIT,
                            /* defaultMaxTotal */  DEFAULT_CONCURRENCY_LIMIT * 4 / 10,
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, 2.0f / 3),
                            List.of(Pair.create(WORK_TYPE_TOP, .7f),
                                    Pair.create(WORK_TYPE_FGS, .1f),
                                    Pair.create(WORK_TYPE_EJ, .1f)),
                                    Pair.create(WORK_TYPE_UI, .1f),
                                    Pair.create(WORK_TYPE_EJ, .05f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, 1.0f / 6),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, 1.0f / 6),
@@ -287,8 +297,9 @@ class JobConcurrencyManager {
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, .3f),
                                    Pair.create(WORK_TYPE_FGS, .2f),
                                    Pair.create(WORK_TYPE_EJ, .3f), Pair.create(WORK_TYPE_BG, .2f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f)),
                                    Pair.create(WORK_TYPE_UI, .2f),
                                    Pair.create(WORK_TYPE_EJ, .15f), Pair.create(WORK_TYPE_BG, .1f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .05f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, .6f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .2f),
@@ -299,8 +310,9 @@ class JobConcurrencyManager {
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, .3f),
                                    Pair.create(WORK_TYPE_FGS, .2f),
                                    Pair.create(WORK_TYPE_EJ, .3f), Pair.create(WORK_TYPE_BG, .2f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f)),
                                    Pair.create(WORK_TYPE_UI, .2f),
                                    Pair.create(WORK_TYPE_EJ, .15f), Pair.create(WORK_TYPE_BG, .1f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .05f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, .5f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f),
@@ -309,9 +321,11 @@ class JobConcurrencyManager {
                    new WorkTypeConfig("screen_off_low", DEFAULT_CONCURRENCY_LIMIT,
                            /* defaultMaxTotal */  DEFAULT_CONCURRENCY_LIMIT * 6 / 10,
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, .4f),
                                    Pair.create(WORK_TYPE_FGS, .1f),
                                    Pair.create(WORK_TYPE_EJ, .2f), Pair.create(WORK_TYPE_BG, .1f)),
                            List.of(Pair.create(WORK_TYPE_TOP, .3f),
                                    Pair.create(WORK_TYPE_FGS, .15f),
                                    Pair.create(WORK_TYPE_UI, .15f),
                                    Pair.create(WORK_TYPE_EJ, .1f), Pair.create(WORK_TYPE_BG, .05f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .05f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, .25f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f),
@@ -320,9 +334,10 @@ class JobConcurrencyManager {
                    new WorkTypeConfig("screen_off_critical", DEFAULT_CONCURRENCY_LIMIT,
                            /* defaultMaxTotal */  DEFAULT_CONCURRENCY_LIMIT * 4 / 10,
                            // defaultMin
                            List.of(Pair.create(WORK_TYPE_TOP, .5f),
                            List.of(Pair.create(WORK_TYPE_TOP, .3f),
                                    Pair.create(WORK_TYPE_FGS, .1f),
                                    Pair.create(WORK_TYPE_EJ, .1f)),
                                    Pair.create(WORK_TYPE_UI, .1f),
                                    Pair.create(WORK_TYPE_EJ, .05f)),
                            // defaultMax
                            List.of(Pair.create(WORK_TYPE_BG, .1f),
                                    Pair.create(WORK_TYPE_BGUSER_IMPORTANT, .1f),
@@ -2078,10 +2093,12 @@ class JobConcurrencyManager {

            if (js.shouldTreatAsExpeditedJob()) {
                classification |= WORK_TYPE_EJ;
            } else if (js.shouldTreatAsUserInitiatedJob()) {
                classification |= WORK_TYPE_UI;
            }
        } else {
            if (js.lastEvaluatedBias >= JobInfo.BIAS_FOREGROUND_SERVICE
                    || js.shouldTreatAsExpeditedJob()) {
                    || js.shouldTreatAsExpeditedJob() || js.shouldTreatAsUserInitiatedJob()) {
                classification |= WORK_TYPE_BGUSER_IMPORTANT;
            }
            // BGUSER_IMPORTANT jobs can also run as BGUSER jobs, so not an 'else' here.
@@ -2101,6 +2118,7 @@ class JobConcurrencyManager {
        static final String KEY_PREFIX_MAX_RATIO = KEY_PREFIX_MAX + "ratio_";
        private static final String KEY_PREFIX_MAX_RATIO_TOP = KEY_PREFIX_MAX_RATIO + "top_";
        private static final String KEY_PREFIX_MAX_RATIO_FGS = KEY_PREFIX_MAX_RATIO + "fgs_";
        private static final String KEY_PREFIX_MAX_RATIO_UI = KEY_PREFIX_MAX_RATIO + "ui_";
        private static final String KEY_PREFIX_MAX_RATIO_EJ = KEY_PREFIX_MAX_RATIO + "ej_";
        private static final String KEY_PREFIX_MAX_RATIO_BG = KEY_PREFIX_MAX_RATIO + "bg_";
        private static final String KEY_PREFIX_MAX_RATIO_BGUSER = KEY_PREFIX_MAX_RATIO + "bguser_";
@@ -2110,6 +2128,7 @@ class JobConcurrencyManager {
        static final String KEY_PREFIX_MIN_RATIO = KEY_PREFIX_MIN + "ratio_";
        private static final String KEY_PREFIX_MIN_RATIO_TOP = KEY_PREFIX_MIN_RATIO + "top_";
        private static final String KEY_PREFIX_MIN_RATIO_FGS = KEY_PREFIX_MIN_RATIO + "fgs_";
        private static final String KEY_PREFIX_MIN_RATIO_UI = KEY_PREFIX_MIN_RATIO + "ui_";
        private static final String KEY_PREFIX_MIN_RATIO_EJ = KEY_PREFIX_MIN_RATIO + "ej_";
        private static final String KEY_PREFIX_MIN_RATIO_BG = KEY_PREFIX_MIN_RATIO + "bg_";
        private static final String KEY_PREFIX_MIN_RATIO_BGUSER = KEY_PREFIX_MIN_RATIO + "bguser_";
@@ -2190,6 +2209,9 @@ class JobConcurrencyManager {
            final int maxFgs = getMaxValue(properties,
                    KEY_PREFIX_MAX_RATIO_FGS + mConfigIdentifier, WORK_TYPE_FGS, oneIntBits);
            mMaxAllowedSlots.put(WORK_TYPE_FGS, maxFgs);
            final int maxUi = getMaxValue(properties,
                    KEY_PREFIX_MAX_RATIO_UI + mConfigIdentifier, WORK_TYPE_UI, oneIntBits);
            mMaxAllowedSlots.put(WORK_TYPE_UI, maxUi);
            final int maxEj = getMaxValue(properties,
                    KEY_PREFIX_MAX_RATIO_EJ + mConfigIdentifier, WORK_TYPE_EJ, oneIntBits);
            mMaxAllowedSlots.put(WORK_TYPE_EJ, maxEj);
@@ -2218,6 +2240,12 @@ class JobConcurrencyManager {
                    0, Math.min(maxFgs, remaining));
            mMinReservedSlots.put(WORK_TYPE_FGS, minFgs);
            remaining -= minFgs;
            // Ensure ui is in the range [0, min(maxUi, remaining)]
            final int minUi = getMinValue(properties,
                    KEY_PREFIX_MIN_RATIO_UI + mConfigIdentifier, WORK_TYPE_UI,
                    0, Math.min(maxUi, remaining));
            mMinReservedSlots.put(WORK_TYPE_UI, minUi);
            remaining -= minUi;
            // Ensure ej is in the range [0, min(maxEj, remaining)]
            final int minEj = getMinValue(properties,
                    KEY_PREFIX_MIN_RATIO_EJ + mConfigIdentifier, WORK_TYPE_EJ,
@@ -2294,6 +2322,12 @@ class JobConcurrencyManager {
            pw.print(KEY_PREFIX_MAX_RATIO_FGS + mConfigIdentifier,
                            mMaxAllowedSlots.get(WORK_TYPE_FGS))
                    .println();
            pw.print(KEY_PREFIX_MIN_RATIO_UI + mConfigIdentifier,
                            mMinReservedSlots.get(WORK_TYPE_UI))
                    .println();
            pw.print(KEY_PREFIX_MAX_RATIO_UI + mConfigIdentifier,
                            mMaxAllowedSlots.get(WORK_TYPE_UI))
                    .println();
            pw.print(KEY_PREFIX_MIN_RATIO_EJ + mConfigIdentifier,
                            mMinReservedSlots.get(WORK_TYPE_EJ))
                    .println();
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_EJ;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_FGS;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_NONE;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_TOP;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_UI;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
@@ -855,6 +856,9 @@ public final class JobConcurrencyManagerTest {
                case WORK_TYPE_FGS:
                    workTypeString = "fgs";
                    break;
                case WORK_TYPE_UI:
                    workTypeString = "ui";
                    break;
                case WORK_TYPE_EJ:
                    workTypeString = "ej";
                    break;
+21 −34
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_BG;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_BGUSER;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_BGUSER_IMPORTANT;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_EJ;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_FGS;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_NONE;
import static com.android.server.job.JobConcurrencyManager.WORK_TYPE_TOP;
import static com.android.server.job.JobConcurrencyManager.workTypeToString;
@@ -59,7 +58,8 @@ public class WorkCountTrackerTest {

    private static final double[] EQUAL_PROBABILITY_CDF =
            buildWorkTypeCdf(1.0 / NUM_WORK_TYPES, 1.0 / NUM_WORK_TYPES, 1.0 / NUM_WORK_TYPES,
                    1.0 / NUM_WORK_TYPES, 1.0 / NUM_WORK_TYPES, 1.0 / NUM_WORK_TYPES);
                    1.0 / NUM_WORK_TYPES, 1.0 / NUM_WORK_TYPES, 1.0 / NUM_WORK_TYPES,
                    1.0 / NUM_WORK_TYPES);

    private Random mRandom;
    private WorkCountTracker mWorkCountTracker;
@@ -72,8 +72,9 @@ public class WorkCountTrackerTest {

    @NonNull
    private static double[] buildWorkTypeCdf(
            double pTop, double pFgs, double pEj, double pBg, double pBgUserImp, double pBgUser) {
        return buildCdf(pTop, pFgs, pEj, pBg, pBgUserImp, pBgUser);
            double pTop, double pFgs, double pUi, double pEj, double pBg,
            double pBgUserImp, double pBgUser) {
        return buildCdf(pTop, pFgs, pUi, pEj, pBg, pBgUserImp, pBgUser);
    }

    @NonNull
@@ -108,23 +109,9 @@ public class WorkCountTrackerTest {

    @JobConcurrencyManager.WorkType
    static int getRandomWorkType(double[] cdf, double rand) {
        assertThat(cdf.length).isEqualTo(NUM_WORK_TYPES);
        final int index = getRandomIndex(cdf, rand);
        switch (index) {
            case 0:
                return WORK_TYPE_TOP;
            case 1:
                return WORK_TYPE_FGS;
            case 2:
                return WORK_TYPE_EJ;
            case 3:
                return WORK_TYPE_BG;
            case 4:
                return WORK_TYPE_BGUSER_IMPORTANT;
            case 5:
                return WORK_TYPE_BGUSER;
            default:
                throw new IllegalStateException("Unknown work type");
        }
        return 1 << index;
    }

    /**
@@ -326,7 +313,7 @@ public class WorkCountTrackerTest {
        final List<Pair<Integer, Float>> maxLimitRatios =
                List.of(Pair.create(WORK_TYPE_BG, 1f), Pair.create(WORK_TYPE_BGUSER, .5f));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(0.5, 0, 0, 0.5, 0, 0);
        final double[] cdf = buildWorkTypeCdf(0.5, 0, 0, 0, 0.5, 0, 0);
        final double[] numTypesCdf = buildCdf(.5, .3, .15, .05);
        final double probStart = 0.5;

@@ -344,7 +331,7 @@ public class WorkCountTrackerTest {
        final List<Pair<Integer, Float>> maxLimitRatios =
                List.of(Pair.create(WORK_TYPE_BG, 1f), Pair.create(WORK_TYPE_BGUSER, .5f));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(1.0 / 3, 0, 0, 1.0 / 3, 0, 1.0 / 3);
        final double[] cdf = buildWorkTypeCdf(1.0 / 3, 0, 0, 0, 1.0 / 3, 0, 1.0 / 3);
        final double[] numTypesCdf = buildCdf(.75, .2, .05);
        final double probStart = 0.5;

@@ -362,7 +349,7 @@ public class WorkCountTrackerTest {
        final List<Pair<Integer, Float>> maxLimitRatios =
                List.of(Pair.create(WORK_TYPE_BG, .2f), Pair.create(WORK_TYPE_BGUSER, .1f));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(1.0 / 3, 0, 0, 1.0 / 3, 0, 1.0 / 3);
        final double[] cdf = buildWorkTypeCdf(1.0 / 3, 0, 0, 0, 1.0 / 3, 0, 1.0 / 3);
        final double[] numTypesCdf = buildCdf(.05, .95);
        final double probStart = 0.5;

@@ -382,7 +369,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 2.0f / 3));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(0.1, 0, 0, 0.8, 0.02, .08);
        final double[] cdf = buildWorkTypeCdf(0.1, 0, 0, 0, 0.8, 0.02, .08);
        final double[] numTypesCdf = buildCdf(.5, .3, .15, .05);
        final double probStart = 0.5;

@@ -402,7 +389,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 3));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(0.85, 0.05, 0, 0.1, 0, 0);
        final double[] cdf = buildWorkTypeCdf(0.8, 0.05, 0.05, 0, 0.1, 0, 0);
        final double[] numTypesCdf = buildCdf(1);
        final double probStart = 0.5;

@@ -422,7 +409,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 3));
        final double probStop = 0.4;
        final double[] cdf = buildWorkTypeCdf(0.1, 0, 0, 0.1, 0.05, .75);
        final double[] cdf = buildWorkTypeCdf(0.1, 0, 0, 0, 0.1, 0.05, .75);
        final double[] numTypesCdf = buildCdf(0.5, 0.5);
        final double probStart = 0.5;

@@ -443,7 +430,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 3));
        final double probStop = 0.4;
        final double[] cdf = buildWorkTypeCdf(0.8, 0.1, 0, 0.05, 0, 0.05);
        final double[] cdf = buildWorkTypeCdf(0.8, 0.1, 0, 0, 0.05, 0, 0.05);
        final double[] numTypesCdf = buildCdf(1);
        final double probStart = 0.5;

@@ -464,7 +451,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 3));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(0, 0, 0, 0.5, 0, 0.5);
        final double[] cdf = buildWorkTypeCdf(0, 0, 0, 0, 0.5, 0, 0.5);
        final double[] numTypesCdf = buildCdf(1);
        final double probStart = 0.5;

@@ -485,7 +472,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 3));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(0, 0, 0, 0.1, 0, 0.9);
        final double[] cdf = buildWorkTypeCdf(0, 0, 0, 0, 0.1, 0, 0.9);
        final double[] numTypesCdf = buildCdf(0.9, 0.1);
        final double probStart = 0.5;

@@ -506,7 +493,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 3));
        final double probStop = 0.5;
        final double[] cdf = buildWorkTypeCdf(0, 0, 0, 0.9, 0, 0.1);
        final double[] cdf = buildWorkTypeCdf(0, 0, .4, 0, 0.5, 0, 0.1);
        final double[] numTypesCdf = buildCdf(1);
        final double probStart = 0.5;

@@ -525,7 +512,7 @@ public class WorkCountTrackerTest {
        final List<Pair<Integer, Float>> maxLimitRatios =
                List.of(Pair.create(WORK_TYPE_BG, 2.0f / 3));
        final double probStop = 0.4;
        final double[] cdf = buildWorkTypeCdf(0.5, 0, 0.5, 0, 0, 0);
        final double[] cdf = buildWorkTypeCdf(0.5, 0, 0.25, 0.25, 0, 0, 0);
        final double[] numTypesCdf = buildCdf(0.1, 0.7, 0.2);
        final double probStart = 0.5;

@@ -566,7 +553,7 @@ public class WorkCountTrackerTest {
        final List<Pair<Integer, Float>> maxLimitRatios =
                List.of(Pair.create(WORK_TYPE_EJ, 5.0f / 6), Pair.create(WORK_TYPE_BG, 2.0f / 3));
        final double probStop = 0.4;
        final double[] cdf = buildWorkTypeCdf(.1, 0, 0.5, 0.35, 0, 0.05);
        final double[] cdf = buildWorkTypeCdf(.1, 0, 0.05, 0.45, 0.35, 0, 0.05);
        final double[] numTypesCdf = buildCdf(1);
        final double probStart = 0.5;

@@ -586,7 +573,7 @@ public class WorkCountTrackerTest {
                List.of(Pair.create(WORK_TYPE_EJ, 5.0f / 6), Pair.create(WORK_TYPE_BG, 2.0f / 3),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 6));
        final double probStop = 0.4;
        final double[] cdf = buildWorkTypeCdf(0.01, 0.09, 0.4, 0.1, 0, 0.4);
        final double[] cdf = buildWorkTypeCdf(0.01, 0.09, 0.2, 0.2, 0.1, 0, 0.4);
        final double[] numTypesCdf = buildCdf(0.7, 0.3);
        final double probStart = 0.5;

@@ -607,7 +594,7 @@ public class WorkCountTrackerTest {
                        Pair.create(WORK_TYPE_BGUSER_IMPORTANT, 1.0f / 7),
                        Pair.create(WORK_TYPE_BGUSER, 1.0f / 7));
        final double probStop = 0.4;
        final double[] cdf = buildWorkTypeCdf(0.01, 0.09, 0.25, 0.05, 0.3, 0.3);
        final double[] cdf = buildWorkTypeCdf(0.01, 0.02, 0.09, 0.25, 0.05, 0.3, 0.3);
        final double[] numTypesCdf = buildCdf(0.7, 0.3);
        final double probStart = 0.5;

+22 −15

File changed.

Preview size limit exceeded, changes collapsed.