dumpsys cpuinfo in Android: Interpreting the results of this command

adb, android, ddms, dumpsys, performance

Solution

adb shell dumpsys cpuinfo

shows info from /proc/stat and /proc/(pid)/stat

1.what does faults represent here ?

Page faults. "minor" for minor faults.

from ProcessCpuTracker.java

collectStats(...) {
  ...
  final long[] procStats = mProcessStatsData;
  if (!Process.readProcFile(st.statFile.toString(),
  PROCESS_STATS_FORMAT, null, procStats, null)) {
  continue;
  }
  ...
  final long minfaults = procStats[PROCESS_STAT_MINOR_FAULTS];
  final long majfaults = procStats[PROCESS_STAT_MAJOR_FAULTS];
}

private static final int[] PROCESS_STATS_FORMAT = new int[] {
  ...
  PROC_SPACE_TERM|PROC_OUT_LONG,                  // 10: minor faults
  ...
  PROC_SPACE_TERM|PROC_OUT_LONG,                  // 12: major faults
  ...
};

They are /proc/(pid)/stat data[9] and data[11].

2.they don't add up to 100

http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages (Linked page from interpreting dumpsys cpuinfo)

With multi-processor system, sum can be more than 100%.

3.are these percentage values averages of the respective processes

from ProcessCpuTracker.java

printProcessCPU(...) {
  ...
  printRatio(pw, user+system+iowait+irq+softIrq, totalTime);
  ...
}

2nd parameter(user+...) / 3rd parameter(totalTime) is printed.

4.CPU usage from 23770ms to 16630ms ago

Times are based on times when stat data cached by ProcessCpuTracker is updated.

from ProcessCpuTracker.java

update() {
  final long nowUptime = SystemClock.uptimeMillis();
  ...
  mLastSampleTime = mCurrentSampleTime;
  mCurrentSampleTime = nowUptime;
  ...
}

[Related sources] https://android.googlesource.com/platform/frameworks/native/+/master/cmds/dumpsys/dumpsys.cpp main() => service->dump()

https://github.com/android/platform_frameworks_base/blob/master/services/core/java/com/android/server/am/ActivityManagerService.java CpuBinder.dump() is called mProcessCpuThread updates stat cache. (updateCpuStatsNow() is called)

https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/os/ProcessCpuTracker.java printCurrentLoad() prints CPU load printCurrentState() prints per process stats

Problem

I'm looking at the out of the following command "adb shell dumpsys cpuinfo" where I want to know if these reported values are averages over previous time ? ``` D:\Android_Dev\Android_sdk\platform-tools>adb shell dumpsys cpuinfo Load: 4.03 / 3.43 / 2.44 CPU usage from 23770ms to 16630ms ago: 58% 1844/logd: 58% user + 0% kernel / faults: 3 minor 50% 3895/com.google.android.wearable.app:ui: 41% user + 9.3% kernel / faults: 1798 minor 26% 1864/adbd: 2.8% user + 23% kernel / faults: 1243 minor 22% 4880/logcat: 7.8% user + 15% kernel 9.7% 7834/kworker/0:2: 0% user + 9.7% kernel 4.9% 2198/system_server: 2.6% user + 2.2% kernel / faults: 76 minor ``` My questions are as follows: - what does faults represent here ? - what does these percentage values represent because they don't add up to 100 ? - are these percentage values averages of the respective processes such as as 58% for logd? - `CPU usage from 23770ms to 16630ms ago:` what does this mean ? does it mean that these values are the average from last 23 to 16 seconds ?

Original source

Related problems