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

Commit 76c3b4f0 authored by Kweku Adams's avatar Kweku Adams
Browse files

Update batching logic.

1. Attempt to piggyback on network activations.
   Have JobScheduler attempt to delay the start of some connectivity
   jobs until the network is actually active. This should help reduce
   the number of network wakeups and the cumulative network
   idle-to-suspend duration.
2. Include jobs in the ACTIVE bucket in the forced batch set and don't
   force batch if we're too close to a job's deadline. However, still
   continue exempt jobs for apps in the EXEMPTED bucket and jobs for
   apps that are currently active (uidActive).

Bug: 28382445
Bug: 299329948
Bug: 299346198
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I58f47c8297b43e72a0b0af16aaf71ace3996166f
parent e27fe837
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
package: "com.android.server.job"

flag {
    name: "batch_active_bucket_jobs"
    namespace: "backstage_power"
    description: "Include jobs in the ACTIVE bucket in the job batching effort. Don't let them run as freely as they're ready."
    bug: "299329948"
}

flag {
    name: "batch_connectivity_jobs_per_network"
    namespace: "backstage_power"
    description: "Have JobScheduler attempt to delay the start of some connectivity jobs until there are several ready or the network is active"
    bug: "28382445"
}

flag {
    name: "do_not_force_rush_execution_at_boot"
    namespace: "backstage_power"
@@ -20,10 +34,3 @@ flag {
    description: "Throw an exception if an unsupported app uses JobInfo.setBias"
    bug: "300477393"
}

flag {
    name: "batch_jobs_on_network_activation"
    namespace: "backstage_power"
    description: "Have JobScheduler attempt to delay the start of some connectivity jobs until the network is actually active"
    bug: "318394184"
}
+0 −1
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ class JobConcurrencyManager {

    static final String CONFIG_KEY_PREFIX_CONCURRENCY = "concurrency_";
    private static final String KEY_CONCURRENCY_LIMIT = CONFIG_KEY_PREFIX_CONCURRENCY + "limit";
    @VisibleForTesting
    static final int DEFAULT_CONCURRENCY_LIMIT;

    static {
+336 −45

File changed.

Preview size limit exceeded, changes collapsed.

+6 −0
Original line number Diff line number Diff line
@@ -350,6 +350,12 @@ public final class JobSchedulerShellCommand extends BasicShellCommandHandler {
            case android.app.job.Flags.FLAG_JOB_DEBUG_INFO_APIS:
                pw.println(android.app.job.Flags.jobDebugInfoApis());
                break;
            case com.android.server.job.Flags.FLAG_BATCH_ACTIVE_BUCKET_JOBS:
                pw.println(com.android.server.job.Flags.batchActiveBucketJobs());
                break;
            case com.android.server.job.Flags.FLAG_BATCH_CONNECTIVITY_JOBS_PER_NETWORK:
                pw.println(com.android.server.job.Flags.batchConnectivityJobsPerNetwork());
                break;
            case com.android.server.job.Flags.FLAG_DO_NOT_FORCE_RUSH_EXECUTION_AT_BOOT:
                pw.println(com.android.server.job.Flags.doNotForceRushExecutionAtBoot());
                break;
+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.job;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.ArraySet;
import android.util.Pools;
import android.util.SparseArray;

@@ -96,10 +97,10 @@ class PendingJobQueue {
        }
    }

    void addAll(@NonNull List<JobStatus> jobs) {
    void addAll(@NonNull ArraySet<JobStatus> jobs) {
        final SparseArray<List<JobStatus>> jobsByUid = new SparseArray<>();
        for (int i = jobs.size() - 1; i >= 0; --i) {
            final JobStatus job = jobs.get(i);
            final JobStatus job = jobs.valueAt(i);
            List<JobStatus> appJobs = jobsByUid.get(job.getSourceUid());
            if (appJobs == null) {
                appJobs = new ArrayList<>();
Loading