Loading cmds/statsd/src/atoms.proto +17 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ message Atom { DiskIo disk_io = 10032; PowerProfile power_profile = 10033; ProcStats proc_stats_pkg_proc = 10034; ProcessCpuTime process_cpu_time = 10035; NativeProcessMemoryState native_process_memory_state = 10036; } Loading Loading @@ -3092,3 +3093,19 @@ message UserRestrictionChanged { // Whether the restriction is enabled or disabled. optional bool enabled = 2; } /** * Pulls process user time and system time. Puller takes a snapshot of all pids * in the system and returns cpu stats for those that are working at the time. * Dead pids will be dropped. Kernel processes are excluded. * Min cool-down is 5 sec. */ message ProcessCpuTime { optional int32 uid = 1 [(is_uid) = true]; optional string process_name = 2; // Process cpu time in user space, cumulative from boot/process start optional int64 user_time_millis = 3; // Process cpu time in system space, cumulative from boot/process start optional int64 system_time_millis = 4; } No newline at end of file cmds/statsd/src/external/StatsPullerManager.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,11 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // PowerProfile constants for power model calculations. {android::util::POWER_PROFILE, {{}, {}, 1 * NS_PER_SEC, new StatsCompanionServicePuller(android::util::POWER_PROFILE)}}, // Process cpu stats. Min cool-down is 5 sec, inline with what AcitivityManagerService uses. {android::util::PROCESS_CPU_TIME, {{} /* additive fields */, {} /* non additive fields */, 5 * NS_PER_SEC /* min cool-down in seconds*/, new StatsCompanionServicePuller(android::util::PROCESS_CPU_TIME)}}, }; StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) { Loading services/core/java/com/android/server/stats/StatsCompanionService.java +28 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import com.android.internal.os.KernelWakelockReader; import com.android.internal.os.KernelWakelockStats; import com.android.internal.os.LooperStats; import com.android.internal.os.PowerProfile; import com.android.internal.os.ProcessCpuTracker; import com.android.internal.os.StoragedUidIoStatsReader; import com.android.internal.util.DumpUtils; import com.android.server.BinderCallsStatsService; Loading Loading @@ -194,6 +195,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private static IThermalService sThermalService; private File mBaseDir = new File(SystemServiceManager.ensureSystemDir(), "stats_companion"); @GuardedBy("this") ProcessCpuTracker mProcessCpuTracker = null; public StatsCompanionService(Context context) { super(); Loading Loading @@ -1420,6 +1423,27 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { }); } private void pullProcessCpuTime(int tagId, long elapsedNanos, final long wallClockNanos, List<StatsLogEventWrapper> pulledData) { synchronized (this) { if (mProcessCpuTracker == null) { mProcessCpuTracker = new ProcessCpuTracker(false); mProcessCpuTracker.init(); } mProcessCpuTracker.update(); for (int i = 0; i < mProcessCpuTracker.countStats(); i++) { ProcessCpuTracker.Stats st = mProcessCpuTracker.getStats(i); StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(st.uid); e.writeString(st.name); e.writeLong(st.base_utime); e.writeLong(st.base_stime); pulledData.add(e); } } } /** * Pulls various data. */ Loading Loading @@ -1554,6 +1578,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { pullPowerProfile(tagId, elapsedNanos, wallClockNanos, ret); break; } case StatsLog.PROCESS_CPU_TIME: { pullProcessCpuTime(tagId, elapsedNanos, wallClockNanos, ret); break; } default: Slog.w(TAG, "No such tagId data as " + tagId); return null; Loading Loading
cmds/statsd/src/atoms.proto +17 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ message Atom { DiskIo disk_io = 10032; PowerProfile power_profile = 10033; ProcStats proc_stats_pkg_proc = 10034; ProcessCpuTime process_cpu_time = 10035; NativeProcessMemoryState native_process_memory_state = 10036; } Loading Loading @@ -3092,3 +3093,19 @@ message UserRestrictionChanged { // Whether the restriction is enabled or disabled. optional bool enabled = 2; } /** * Pulls process user time and system time. Puller takes a snapshot of all pids * in the system and returns cpu stats for those that are working at the time. * Dead pids will be dropped. Kernel processes are excluded. * Min cool-down is 5 sec. */ message ProcessCpuTime { optional int32 uid = 1 [(is_uid) = true]; optional string process_name = 2; // Process cpu time in user space, cumulative from boot/process start optional int64 user_time_millis = 3; // Process cpu time in system space, cumulative from boot/process start optional int64 system_time_millis = 4; } No newline at end of file
cmds/statsd/src/external/StatsPullerManager.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,11 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // PowerProfile constants for power model calculations. {android::util::POWER_PROFILE, {{}, {}, 1 * NS_PER_SEC, new StatsCompanionServicePuller(android::util::POWER_PROFILE)}}, // Process cpu stats. Min cool-down is 5 sec, inline with what AcitivityManagerService uses. {android::util::PROCESS_CPU_TIME, {{} /* additive fields */, {} /* non additive fields */, 5 * NS_PER_SEC /* min cool-down in seconds*/, new StatsCompanionServicePuller(android::util::PROCESS_CPU_TIME)}}, }; StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) { Loading
services/core/java/com/android/server/stats/StatsCompanionService.java +28 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import com.android.internal.os.KernelWakelockReader; import com.android.internal.os.KernelWakelockStats; import com.android.internal.os.LooperStats; import com.android.internal.os.PowerProfile; import com.android.internal.os.ProcessCpuTracker; import com.android.internal.os.StoragedUidIoStatsReader; import com.android.internal.util.DumpUtils; import com.android.server.BinderCallsStatsService; Loading Loading @@ -194,6 +195,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private static IThermalService sThermalService; private File mBaseDir = new File(SystemServiceManager.ensureSystemDir(), "stats_companion"); @GuardedBy("this") ProcessCpuTracker mProcessCpuTracker = null; public StatsCompanionService(Context context) { super(); Loading Loading @@ -1420,6 +1423,27 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { }); } private void pullProcessCpuTime(int tagId, long elapsedNanos, final long wallClockNanos, List<StatsLogEventWrapper> pulledData) { synchronized (this) { if (mProcessCpuTracker == null) { mProcessCpuTracker = new ProcessCpuTracker(false); mProcessCpuTracker.init(); } mProcessCpuTracker.update(); for (int i = 0; i < mProcessCpuTracker.countStats(); i++) { ProcessCpuTracker.Stats st = mProcessCpuTracker.getStats(i); StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(st.uid); e.writeString(st.name); e.writeLong(st.base_utime); e.writeLong(st.base_stime); pulledData.add(e); } } } /** * Pulls various data. */ Loading Loading @@ -1554,6 +1578,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { pullPowerProfile(tagId, elapsedNanos, wallClockNanos, ret); break; } case StatsLog.PROCESS_CPU_TIME: { pullProcessCpuTime(tagId, elapsedNanos, wallClockNanos, ret); break; } default: Slog.w(TAG, "No such tagId data as " + tagId); return null; Loading