summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorOlivier Gaillard <gaillard@google.com>2018-07-10 11:25:09 +0100
committerOlivier Gaillard <gaillard@google.com>2018-07-11 10:44:49 +0100
commit00bfb1b95a72ed0798c10bc12f9309422e6ab0bf (patch)
tree1d80c93ccb24d9100d674132745d1c90dfc0b868 /core/java
parent89b325a9b9127a43a96be1df1992a84404217d23 (diff)
Collects binder call stats data through WestWorld.
We require binder calls detailed tracking to be enabled to collect the stats (in addition to enabling it in WestWorld). Test: unit test + manual adb shell cmd stats pull-source 10022 Pull from 10022: { 1531240941000000000 25807560798 (10022)0x10000->0[I] 0x20000->com.android.server.StorageManagerService$3[S] 0x30000->onVolumePathChanged[S] 0x40000->1[L] 0x50000->0[L] 0x60000->18490[L] 0x70000->18490[L] 0x80000->2611[L] 0x90000->2611[L] 0xa0000->0[L] } ... Change-Id: I07cad5d8678426cdac45872cda028ea7a85d7d81
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/os/BinderCallsStats.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java
index 6177923d83c6..f87c081fd04f 100644
--- a/core/java/com/android/internal/os/BinderCallsStats.java
+++ b/core/java/com/android/internal/os/BinderCallsStats.java
@@ -24,6 +24,7 @@ import android.text.format.DateFormat;
import android.util.ArrayMap;
import android.util.Log;
import android.util.Pair;
+import android.util.Slog;
import android.util.SparseArray;
import com.android.internal.annotations.GuardedBy;
@@ -212,6 +213,39 @@ public class BinderCallsStats {
}
}
+ public ArrayList<ExportedCallStat> getExportedCallStats() {
+ // We do not collect all the data if detailed tracking is off.
+ if (!mDetailedTracking) {
+ return new ArrayList<ExportedCallStat>();
+ }
+
+ ArrayList<ExportedCallStat> resultCallStats = new ArrayList<>();
+ synchronized (mLock) {
+ int uidEntriesSize = mUidEntries.size();
+ for (int entryIdx = 0; entryIdx < uidEntriesSize; entryIdx++){
+ UidEntry entry = mUidEntries.valueAt(entryIdx);
+ for (CallStat stat : entry.getCallStatsList()) {
+ ExportedCallStat exported = new ExportedCallStat();
+ exported.uid = entry.uid;
+ exported.className = stat.className;
+ exported.methodName = stat.methodName == null
+ ? String.valueOf(stat.msg) : stat.methodName;
+ exported.cpuTimeMicros = stat.cpuTimeMicros;
+ exported.maxCpuTimeMicros = stat.maxCpuTimeMicros;
+ exported.latencyMicros = stat.latencyMicros;
+ exported.maxLatencyMicros = stat.maxLatencyMicros;
+ exported.callCount = stat.callCount;
+ exported.maxRequestSizeBytes = stat.maxRequestSizeBytes;
+ exported.maxReplySizeBytes = stat.maxReplySizeBytes;
+ exported.exceptionCount = stat.exceptionCount;
+ resultCallStats.add(exported);
+ }
+ }
+ }
+
+ return resultCallStats;
+ }
+
public void dump(PrintWriter pw, Map<Integer,String> appIdToPkgNameMap, boolean verbose) {
synchronized (mLock) {
dumpLocked(pw, appIdToPkgNameMap, verbose);
@@ -372,6 +406,23 @@ public class BinderCallsStats {
}
}
+ /**
+ * Aggregated data by uid/class/method to be sent through WestWorld.
+ */
+ public static class ExportedCallStat {
+ public int uid;
+ public String className;
+ public String methodName;
+ public long cpuTimeMicros;
+ public long maxCpuTimeMicros;
+ public long latencyMicros;
+ public long maxLatencyMicros;
+ public long callCount;
+ public long maxRequestSizeBytes;
+ public long maxReplySizeBytes;
+ public long exceptionCount;
+ }
+
@VisibleForTesting
public static class CallStat {
public String className;