diff options
| author | 2023-04-10 15:21:44 -0600 | |
|---|---|---|
| committer | 2023-04-11 00:36:32 +0000 | |
| commit | 3f400959e29ba57ed69676f87744fb887422ef30 (patch) | |
| tree | b8ac9314629a1200d11be1de135c029ece975ec3 | |
| parent | 1be684590b24d84222a2674c167ce1147d7ac68e (diff) | |
BroadcastQueue: Initial deterministic perf test.
As we start working on the "modern" alternative broadcast queue
implementation, we'd like to gain confidence that we're actually
improving the metrics we care about, without having to wait for
changes to deploy to wider user populations.
Instead of writing these using a traditional timing approach (which
can suffer from scheduling noise), we explore "playing back" a set
of well-known pathological scenarios, which will result in a
deterministic output that can be used to immediately judge if a
given CL improves or regresses a measured metric.
Bug: 245771249
Test: atest FrameworksMockingServicesTests:BroadcastQueueTest
Change-Id: I6f562c0b6f2a71fef52aae013899de7f2f95bc71
| -rw-r--r-- | services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java | 40 |
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 64a95ca843d3..eb66d6495168 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 |