Loading apct-tests/perftests/core/src/android/os/BinderCallsStatsPerfTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class BinderCallsStatsPerfTest { int i = 0; while (state.keepRunning()) { BinderCallsStats.CallSession s = mBinderCallsStats.callStarted(b, i % 100); mBinderCallsStats.callEnded(s); mBinderCallsStats.callEnded(s, 0, 0); i++; } } Loading @@ -71,7 +71,7 @@ public class BinderCallsStatsPerfTest { mBinderCallsStats = new BinderCallsStats(false); while (state.keepRunning()) { BinderCallsStats.CallSession s = mBinderCallsStats.callStarted(b, 0); mBinderCallsStats.callEnded(s); mBinderCallsStats.callEnded(s, 0, 0); } } Loading core/java/android/os/Binder.java +3 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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; } Loading core/java/com/android/internal/os/BinderCallsStats.java +16 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -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); } Loading Loading @@ -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; Loading core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java +24 −7 Original line number Diff line number Diff line Loading @@ -35,7 +35,9 @@ import static org.junit.Assert.assertEquals; @RunWith(AndroidJUnit4.class) @Presubmit public class BinderCallsStatsTest { public static final int TEST_UID = 1; private static final int TEST_UID = 1; private static final int REQUEST_SIZE = 2; private static final int REPLY_SIZE = 3; @Test public void testDetailedOff() { Loading @@ -43,7 +45,7 @@ public class BinderCallsStatsTest { Binder binder = new Binder(); BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); bcs.time += 10; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); SparseArray<BinderCallsStats.UidEntry> uidEntries = bcs.getUidEntries(); assertEquals(1, uidEntries.size()); Loading @@ -66,7 +68,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 1); bcs.time += 20; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(2, uidEntry.callCount); Loading @@ -79,7 +81,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 2); bcs.time += 50; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(3, uidEntry.callCount); Loading @@ -95,7 +97,7 @@ public class BinderCallsStatsTest { Binder binder = new Binder(); BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); bcs.time += 10; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); SparseArray<BinderCallsStats.UidEntry> uidEntries = bcs.getUidEntries(); assertEquals(1, uidEntries.size()); Loading @@ -117,7 +119,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 1); bcs.time += 20; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(2, uidEntry.callCount); Loading @@ -127,7 +129,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 2); bcs.time += 50; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(3, uidEntry.callCount); Loading @@ -137,6 +139,21 @@ public class BinderCallsStatsTest { assertEquals(2, callStatsList.size()); } @Test public void testParcelSize() { TestBinderCallsStats bcs = new TestBinderCallsStats(true); Binder binder = new Binder(); BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); bcs.time += 10; bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); List<BinderCallsStats.CallStat> callStatsList = bcs.getUidEntries().get(TEST_UID).getCallStatsList(); assertEquals(REQUEST_SIZE, callStatsList.get(0).maxRequestSizeBytes); assertEquals(REPLY_SIZE, callStatsList.get(0).maxReplySizeBytes); } @Test public void testGetHighestValues() { List<Integer> list = Arrays.asList(1, 2, 3, 4); Loading Loading
apct-tests/perftests/core/src/android/os/BinderCallsStatsPerfTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class BinderCallsStatsPerfTest { int i = 0; while (state.keepRunning()) { BinderCallsStats.CallSession s = mBinderCallsStats.callStarted(b, i % 100); mBinderCallsStats.callEnded(s); mBinderCallsStats.callEnded(s, 0, 0); i++; } } Loading @@ -71,7 +71,7 @@ public class BinderCallsStatsPerfTest { mBinderCallsStats = new BinderCallsStats(false); while (state.keepRunning()) { BinderCallsStats.CallSession s = mBinderCallsStats.callStarted(b, 0); mBinderCallsStats.callEnded(s); mBinderCallsStats.callEnded(s, 0, 0); } } Loading
core/java/android/os/Binder.java +3 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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; } Loading
core/java/com/android/internal/os/BinderCallsStats.java +16 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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) { Loading @@ -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); } Loading Loading @@ -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; Loading
core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java +24 −7 Original line number Diff line number Diff line Loading @@ -35,7 +35,9 @@ import static org.junit.Assert.assertEquals; @RunWith(AndroidJUnit4.class) @Presubmit public class BinderCallsStatsTest { public static final int TEST_UID = 1; private static final int TEST_UID = 1; private static final int REQUEST_SIZE = 2; private static final int REPLY_SIZE = 3; @Test public void testDetailedOff() { Loading @@ -43,7 +45,7 @@ public class BinderCallsStatsTest { Binder binder = new Binder(); BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); bcs.time += 10; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); SparseArray<BinderCallsStats.UidEntry> uidEntries = bcs.getUidEntries(); assertEquals(1, uidEntries.size()); Loading @@ -66,7 +68,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 1); bcs.time += 20; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(2, uidEntry.callCount); Loading @@ -79,7 +81,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 2); bcs.time += 50; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(3, uidEntry.callCount); Loading @@ -95,7 +97,7 @@ public class BinderCallsStatsTest { Binder binder = new Binder(); BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); bcs.time += 10; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); SparseArray<BinderCallsStats.UidEntry> uidEntries = bcs.getUidEntries(); assertEquals(1, uidEntries.size()); Loading @@ -117,7 +119,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 1); bcs.time += 20; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(2, uidEntry.callCount); Loading @@ -127,7 +129,7 @@ public class BinderCallsStatsTest { callSession = bcs.callStarted(binder, 2); bcs.time += 50; bcs.callEnded(callSession); bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); uidEntry = bcs.getUidEntries().get(TEST_UID); assertEquals(3, uidEntry.callCount); Loading @@ -137,6 +139,21 @@ public class BinderCallsStatsTest { assertEquals(2, callStatsList.size()); } @Test public void testParcelSize() { TestBinderCallsStats bcs = new TestBinderCallsStats(true); Binder binder = new Binder(); BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); bcs.time += 10; bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); List<BinderCallsStats.CallStat> callStatsList = bcs.getUidEntries().get(TEST_UID).getCallStatsList(); assertEquals(REQUEST_SIZE, callStatsList.get(0).maxRequestSizeBytes); assertEquals(REPLY_SIZE, callStatsList.get(0).maxReplySizeBytes); } @Test public void testGetHighestValues() { List<Integer> list = Arrays.asList(1, 2, 3, 4); Loading