Add Standby Bucket and job duration to ScheduledJobStateChanged atom.
This fields enable us to slice job metrics by bucket and gain insight to the average time spent executing jobs in each bucket. The metrics we'll write for this data will help to tune thresholds for throttling background behavior in Q. BUG: 132227621 Test: make statsd_testdrive && statsd_testdrive 8 Change-Id: I1af94dc4a8e51f9741f48c817d1d2f99f164858d
This commit is contained in:
@@ -745,6 +745,22 @@ message ScheduledJobStateChanged {
|
||||
// This is only applicable when the state is FINISHED.
|
||||
// The default value is STOP_REASON_UNKNOWN.
|
||||
optional android.app.job.StopReasonEnum stop_reason = 4;
|
||||
|
||||
// The standby bucket of the app that scheduled the job. These match the framework constants
|
||||
// defined in JobSchedulerService.java with the addition of UNKNOWN using -1, as ACTIVE is
|
||||
// already assigned 0.
|
||||
enum Bucket {
|
||||
UNKNOWN = -1;
|
||||
ACTIVE = 0;
|
||||
WORKING_SET = 1;
|
||||
FREQUENT = 2;
|
||||
RARE = 3;
|
||||
NEVER = 4;
|
||||
}
|
||||
optional Bucket standby_bucket = 5 [default = UNKNOWN];
|
||||
|
||||
// The job id (as assigned by the app).
|
||||
optional int32 job_id = 6;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,8 +71,8 @@ interface IBatteryStats {
|
||||
|
||||
void noteSyncStart(String name, int uid);
|
||||
void noteSyncFinish(String name, int uid);
|
||||
void noteJobStart(String name, int uid);
|
||||
void noteJobFinish(String name, int uid, int stopReason);
|
||||
void noteJobStart(String name, int uid, int standbyBucket, int jobid);
|
||||
void noteJobFinish(String name, int uid, int stopReason, int standbyBucket, int jobid);
|
||||
|
||||
void noteStartWakelock(int uid, int pid, String name, String historyName,
|
||||
int type, boolean unimportantForLogging);
|
||||
|
||||
@@ -467,23 +467,25 @@ public final class BatteryStatsService extends IBatteryStats.Stub
|
||||
}
|
||||
}
|
||||
|
||||
public void noteJobStart(String name, int uid) {
|
||||
/** A scheduled job was started. */
|
||||
public void noteJobStart(String name, int uid, int standbyBucket, int jobid) {
|
||||
enforceCallingPermission();
|
||||
synchronized (mStats) {
|
||||
mStats.noteJobStartLocked(name, uid);
|
||||
StatsLog.write_non_chained(StatsLog.SCHEDULED_JOB_STATE_CHANGED, uid, null,
|
||||
name, StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__STARTED,
|
||||
JobProtoEnums.STOP_REASON_UNKNOWN);
|
||||
JobProtoEnums.STOP_REASON_UNKNOWN, standbyBucket, jobid);
|
||||
}
|
||||
}
|
||||
|
||||
public void noteJobFinish(String name, int uid, int stopReason) {
|
||||
/** A scheduled job was finished. */
|
||||
public void noteJobFinish(String name, int uid, int stopReason, int standbyBucket, int jobid) {
|
||||
enforceCallingPermission();
|
||||
synchronized (mStats) {
|
||||
mStats.noteJobFinishLocked(name, uid, stopReason);
|
||||
StatsLog.write_non_chained(StatsLog.SCHEDULED_JOB_STATE_CHANGED, uid, null,
|
||||
name, StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__FINISHED,
|
||||
stopReason);
|
||||
stopReason, standbyBucket, jobid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1057,7 +1057,8 @@ public class JobSchedulerService extends com.android.server.SystemService
|
||||
StatsLog.write_non_chained(StatsLog.SCHEDULED_JOB_STATE_CHANGED,
|
||||
uId, null, jobStatus.getBatteryName(),
|
||||
StatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__SCHEDULED,
|
||||
JobProtoEnums.STOP_REASON_CANCELLED);
|
||||
JobProtoEnums.STOP_REASON_CANCELLED, jobStatus.getStandbyBucket(),
|
||||
jobStatus.getJobId());
|
||||
|
||||
// If the job is immediately ready to run, then we can just immediately
|
||||
// put it in the pending list and try to schedule it. This is especially
|
||||
|
||||
@@ -265,7 +265,8 @@ public final class JobServiceContext implements ServiceConnection {
|
||||
}
|
||||
mJobPackageTracker.noteActive(job);
|
||||
try {
|
||||
mBatteryStats.noteJobStart(job.getBatteryName(), job.getSourceUid());
|
||||
mBatteryStats.noteJobStart(job.getBatteryName(), job.getSourceUid(),
|
||||
job.getStandbyBucket(), job.getJobId());
|
||||
} catch (RemoteException e) {
|
||||
// Whatever.
|
||||
}
|
||||
@@ -774,7 +775,8 @@ public final class JobServiceContext implements ServiceConnection {
|
||||
mJobPackageTracker.noteInactive(completedJob, mParams.getStopReason(), reason);
|
||||
try {
|
||||
mBatteryStats.noteJobFinish(mRunningJob.getBatteryName(),
|
||||
mRunningJob.getSourceUid(), mParams.getStopReason());
|
||||
mRunningJob.getSourceUid(), mParams.getStopReason(),
|
||||
mRunningJob.getStandbyBucket(), mRunningJob.getJobId());
|
||||
} catch (RemoteException e) {
|
||||
// Whatever.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user