summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorOlivier Gaillard <gaillard@google.com>2018-06-04 10:07:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-06-04 10:07:47 +0000
commit22e64ec6116c16b550c51ecafaea31510db97b55 (patch)
tree1c8246b5be02f1f3f6be9b41314b81e4ad2e82dd /core/java
parentfa38f94154be370f84b98cf02efb277775cbf15b (diff)
parent58b56e3720823c10e654648ebe9cabb761c2579b (diff)
Merge "Collect a few more binder stats when detailed tracking is enabled."
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/Binder.java4
-rw-r--r--core/java/com/android/internal/os/BinderCallsStats.java20
2 files changed, 19 insertions, 5 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 7e7d6170feca..1e6f1acb55a8 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -760,6 +760,8 @@ public class Binder implements IBinder {
}
}
checkParcel(this, code, reply, "Unreasonably large binder reply buffer");
+ int replySizeBytes = reply.dataSize();
+ int requestSizeBytes = data.dataSize();
reply.recycle();
data.recycle();
@@ -769,7 +771,7 @@ public class Binder implements IBinder {
// to the main transaction loop to wait for another incoming transaction. Either
// way, strict mode begone!
StrictMode.clearGatheredViolations();
- binderCallsStats.callEnded(callSession);
+ binderCallsStats.callEnded(callSession, requestSizeBytes, replySizeBytes);
return res;
}
diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java
index ec89d8127e5a..fbb99e423cd6 100644
--- a/core/java/com/android/internal/os/BinderCallsStats.java
+++ b/core/java/com/android/internal/os/BinderCallsStats.java
@@ -92,7 +92,7 @@ public class BinderCallsStats {
return s;
}
- public void callEnded(CallSession s) {
+ public void callEnded(CallSession s, int parcelRequestSize, int parcelReplySize) {
Preconditions.checkNotNull(s);
synchronized (mLock) {
long duration;
@@ -110,7 +110,7 @@ public class BinderCallsStats {
// callCount is always incremented, but time only once per sampling interval
long samplesCount = cs.callCount / PERIODIC_SAMPLING_INTERVAL + 1;
duration = cs.cpuTimeMicros / samplesCount;
- latencyDuration = cs.latencyMicros/ samplesCount;
+ latencyDuration = cs.latencyMicros / samplesCount;
}
}
@@ -129,6 +129,11 @@ public class BinderCallsStats {
callStat.cpuTimeMicros += duration;
callStat.latencyMicros += latencyDuration;
callStat.exceptionCount += s.exceptionThrown ? 1 : 0;
+ callStat.maxLatencyMicros = Math.max(callStat.maxLatencyMicros, latencyDuration);
+ callStat.maxRequestSizeBytes =
+ Math.max(callStat.maxRequestSizeBytes, parcelRequestSize);
+ callStat.maxReplySizeBytes =
+ Math.max(callStat.maxReplySizeBytes, parcelReplySize);
} else {
// update sampled timings in the beginning of each interval
if (s.cpuTimeStarted >= 0) {
@@ -184,8 +189,9 @@ public class BinderCallsStats {
StringBuilder sb = new StringBuilder();
if (mDetailedTracking) {
pw.println("Per-UID raw data " + datasetSizeDesc
- + "(uid, call_desc, cpu_time_micros, latency_time_micros, exception_count, "
- + "call_count):");
+ + "(uid, call_desc, cpu_time_micros, latency_time_micros, "
+ + "max_latency_time_micros, exception_count, max_request_size_bytes, "
+ + "max_reply_size_bytes, call_count):");
List<UidEntry> topEntries = verbose ? entries
: getHighestValues(entries, value -> value.cpuTimeMicros, 0.9);
for (UidEntry uidEntry : topEntries) {
@@ -195,7 +201,10 @@ public class BinderCallsStats {
.append(uidEntry.uid).append(",").append(e)
.append(',').append(e.cpuTimeMicros)
.append(',').append(e.latencyMicros)
+ .append(',').append(e.maxLatencyMicros)
.append(',').append(e.exceptionCount)
+ .append(',').append(e.maxRequestSizeBytes)
+ .append(',').append(e.maxReplySizeBytes)
.append(',').append(e.callCount);
pw.println(sb);
}
@@ -280,6 +289,9 @@ public class BinderCallsStats {
public int msg;
public long cpuTimeMicros;
public long latencyMicros;
+ public long maxLatencyMicros;
+ public long maxRequestSizeBytes;
+ public long maxReplySizeBytes;
public long callCount;
public long exceptionCount;