summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-04-11 02:10:10 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-04-11 02:10:10 +0000
commit9bed03d515df9deab985a8367fb0ff22dd94416f (patch)
tree2d2c5d9ea80bbae6d9049b14be3a88976b0c41f6
parent43d7854d416c1e2fe432c0443af73fc22edc4d3e (diff)
parent3f400959e29ba57ed69676f87744fb887422ef30 (diff)
Merge "BroadcastQueue: Initial deterministic perf test." into udc-dev
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java
index d7ba3df07533..90e6a2d0f34a 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java
@@ -1981,6 +1981,46 @@ public class BroadcastQueueTest {
}
/**
+ * Confirm how many times a pathological broadcast pattern results in OOM
+ * adjusts; watches for performance regressions.
+ */
+ @Test
+ public void testOomAdjust_TriggerCount() throws Exception {
+ final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_RED);
+
+ // Send 8 broadcasts, 4 receivers in the first process,
+ // and 2 alternating in each of the remaining processes
+ synchronized (mAms) {
+ for (int i = 0; i < 8; i++) {
+ final Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED);
+ mQueue.enqueueBroadcastLocked(makeBroadcastRecord(intent, callerApp,
+ List.of(makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN),
+ makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN),
+ makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN),
+ makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN),
+ makeManifestReceiver(PACKAGE_BLUE, CLASS_BLUE),
+ makeManifestReceiver(PACKAGE_YELLOW, CLASS_YELLOW),
+ makeManifestReceiver(PACKAGE_BLUE, CLASS_BLUE),
+ makeManifestReceiver(PACKAGE_YELLOW, CLASS_YELLOW))));
+ }
+ }
+ waitForIdle();
+
+ final int expectedTimes;
+ switch (mImpl) {
+ // Original stack requested for every single receiver; yikes
+ case DEFAULT: expectedTimes = 64; break;
+ // Modern stack requests once each time we promote a process to
+ // running; we promote "green" twice, and "blue" and "yellow" once
+ case MODERN: expectedTimes = 4; break;
+ default: throw new UnsupportedOperationException();
+ }
+
+ verify(mAms, times(expectedTimes))
+ .updateOomAdjPendingTargetsLocked(eq(OOM_ADJ_REASON_START_RECEIVER));
+ }
+
+ /**
* Verify that expected events are triggered when a broadcast is finished.
*/
@Test