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

Commit 0ca706bb authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Report total latency instead of average for jobs last run

Instead of computing the average on the device, upload the
total sum of the latencies. Server can divide by the event count
if it wants to get the average.

Also change the latency buckets to 1 hr, 2 hrs, 4 hrs, 8 hrs and
greater than 8 hrs.

Bug: 70297451
Test: launch an app
      dumpsys batterystats --checkin | grep jbd,
      Observe the dumped values for the app

Change-Id: Iecda808594fc960fb16fa0407e5875bbc47db43a
parent c42546ed
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -294,8 +294,8 @@ public abstract class BatteryStats implements Parcelable {
    /**
     * jbd line is:
     * BATTERY_STATS_CHECKIN_VERSION, uid, which, "jbd",
     * jobsDeferredEventCount, jobsDeferredCount, averageLatencyMillis,
     * count at latency < 1 hr, count at latency < 2 hrs, count at latency < 6 hrs, beyond 6 hrs
     * jobsDeferredEventCount, jobsDeferredCount, totalLatencyMillis,
     * count at latency < 1 hr, count at latency 1 to 2 hrs, 2 to 4 hrs, 4 to 8 hrs, and past 8 hrs
     * <p>
     * @see #JOB_FRESHNESS_BUCKETS
     */
@@ -364,13 +364,14 @@ public abstract class BatteryStats implements Parcelable {
    /**
     * These are the thresholds for bucketing last time since a job was run for an app
     * that just moved to ACTIVE due to a launch. So if the last time a job ran was less
     * than 30 minutes ago, then it's reasonably fresh, 2 hours ago, not so fresh and so
     * than 1 hour ago, then it's reasonably fresh, 2 hours ago, not so fresh and so
     * on.
     */
    public static final long[] JOB_FRESHNESS_BUCKETS = {
            1 * 60 * 60 * 1000L,
            2 * 60 * 60 * 1000L,
            6 * 60 * 60 * 1000L,
            4 * 60 * 60 * 1000L,
            8 * 60 * 60 * 1000L,
            Long.MAX_VALUE
    };

+4 −8
Original line number Diff line number Diff line
@@ -7872,12 +7872,10 @@ public class BatteryStatsImpl extends BatteryStats {
                return;
            }
            final int deferredCount = mJobsDeferredCount.getCountLocked(which);
            final long averageLatency = deferredEventCount != 0
                    ? mJobsFreshnessTimeMs.getCountLocked(which) / deferredEventCount
                    : 0L;
            final long totalLatency = mJobsFreshnessTimeMs.getCountLocked(which);
            sb.append(deferredEventCount); sb.append(',');
            sb.append(deferredCount); sb.append(',');
            sb.append(averageLatency);
            sb.append(totalLatency);
            for (int i = 0; i < JOB_FRESHNESS_BUCKETS.length; i++) {
                if (mJobsFreshnessBuckets[i] == null) {
                    sb.append(",0");
@@ -7896,12 +7894,10 @@ public class BatteryStatsImpl extends BatteryStats {
                return;
            }
            final int deferredCount = mJobsDeferredCount.getCountLocked(which);
            final long averageLatency = deferredEventCount != 0
                    ? mJobsFreshnessTimeMs.getCountLocked(which) / deferredEventCount
                    : 0L;
            final long totalLatency = mJobsFreshnessTimeMs.getCountLocked(which);
            sb.append("times="); sb.append(deferredEventCount); sb.append(", ");
            sb.append("count="); sb.append(deferredCount); sb.append(", ");
            sb.append("avgLatency="); sb.append(averageLatency); sb.append(", ");
            sb.append("totalLatencyMs="); sb.append(totalLatency); sb.append(", ");
            for (int i = 0; i < JOB_FRESHNESS_BUCKETS.length; i++) {
                sb.append("<"); sb.append(JOB_FRESHNESS_BUCKETS[i]); sb.append("ms=");
                if (mJobsFreshnessBuckets[i] == null) {